Index: theme/theme.inc =================================================================== --- theme/theme.inc (.../6.x-2.11) (revision 2385) +++ theme/theme.inc (.../6.x-2.11-patched1) (revision 2385) @@ -36,6 +36,47 @@ } /** + * Generates a unique dom id for the view. + * @param $view + * view object + * @return + * string id + */ +function _views_generate_dom_id($view) { + //If dom_id property is already set, use it as identifier + if (!empty($view->dom_id)) { + return $view->dom_id; + } + //It allows clients to set the dom_id per request as they may bypass the views_ajax() function + //with a custom menu call back and the invokation of views_embed_view(). It is needed when + //the same display is rendered mulitple times on a common HTML page by separate requests. + //Clients are supposed to look up the view_dom_id entry the Drupal.settings.views.AjaxViews + //array and calculate a unique id by themselves. + elseif (isset($_REQUEST['view_dom_id'])) { + return $_REQUEST['view_dom_id']; + } + //It provides a unique identifier per request. It is needed when the same view display is rendered + //multiple times on a common HTML page within the same request. The ID is determined by the view's + //name, display name and an incremential counter. It also prevents ID clashing if different view + //displays are rendered by separate requests. This wouldn't be avoided by an incremental counter only. + else { + static $dom_ids = array(); //store dom ids within one request + $counter = 0; + do { + //dom id, e. g. view-display-1 + $unique_dom_id = form_clean_id($view->name . '-' . $view->current_display . '-' . ++$counter); + //check if dom ids already exists, otherwise increment counter with next loop iteration + if (!in_array($unique_dom_id, $dom_ids)) { + $dom_ids[] = $unique_dom_id; + return $unique_dom_id; + } + } while ($counter <= count($dom_ids)); + //shouldn't happen, but just in case assign a unique id with timestamp + return form_clean_id($view->name . '-' . $view->current_display . '-' . time()); + } +} + +/** * Preprocess the primary theme implementation for a view. */ function template_preprocess_views_view(&$vars) { @@ -137,8 +178,7 @@ // we set up a running counter, $dom_id, to issue a "unique" identifier for // each view. This identifier is written to both Drupal.settings and the DIV // wrapper. - static $dom_id = 1; - $vars['dom_id'] = !empty($view->dom_id) ? $view->dom_id : $dom_id++; + $vars['dom_id'] = _views_generate_dom_id($view); $vars['classes_array'][] = 'view-dom-id-' . $vars['dom_id']; // If using AJAX, send identifying data about this view. Index: includes/ajax.inc =================================================================== --- includes/ajax.inc (.../6.x-2.11) (revision 2385) +++ includes/ajax.inc (.../6.x-2.11-patched1) (revision 2385) @@ -19,7 +19,7 @@ $display_id = $_REQUEST['view_display_id']; $args = isset($_REQUEST['view_args']) && $_REQUEST['view_args'] !== '' ? explode('/', $_REQUEST['view_args']) : array(); $path = isset($_REQUEST['view_path']) ? $_REQUEST['view_path'] : NULL; - $dom_id = isset($_REQUEST['view_dom_id']) ? intval($_REQUEST['view_dom_id']) : NULL; + $dom_id = isset($_REQUEST['view_dom_id']) ? $_REQUEST['view_dom_id'] : NULL; $pager_element = isset($_REQUEST['pager_element']) ? intval($_REQUEST['pager_element']) : NULL; views_include('ajax'); $object = new stdClass();