I am working on a magazine site. We have Issues, and Issues have Articles. I have created a view that lists Articles based on the related Issue (one at a time, with a pager). I have created another View that lists Issue's Covers (one at a time, with a pager), and used a .tpl file to embed the list_articles view.

The end result is one Issue Cover, and one related Article. When I click the pager for the Article (I have changed Pager Element so there is no conflict with multiple pagers), it displays (using AJAX) the expected Article in place of the existing one. So far so good.

When I click the pager for the Issue Cover, the Issue Cover and related Article change as expected, sort of.

The problem is, if I was last looking at Article Pager 3 on Issue 1, when I click the Issue Cover Pager the Article Pager remains on '3'. Is there any way to force the child view to reset the pager value to '0'?

One workaround I am considering if I can't get the child view's pager to reset is to use Views Carousel to display my Issue Covers, which also has it's limitations but will get me most of the way there (kinda works in my tests, just needs styling). Maybe JQuery Carousel has a way of adding a pager.

Thanks!

Comments

spyderboy’s picture

Here is what worked for me (in template.php):

/**
* Implementation of theme_pager_link()
*
* @see http://api.drupal.org/api/function/theme_pager_link/6
*/
function mythemename_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
  $page = isset($_GET['page']) ? $_GET['page'] : '';

  // reset pager info if Issue pager is clicked
  if ($element == "1") {
  // "1" is the id assigned to the issue_teaser view's pager element 
  // wipe 'page' var so we start fresh with each new issue by 'popping' the value off the end of the array
  // sub view MUST be the highest $element value for this to work.
  $page=array_pop(explode(',', $page));
  } 
  // end pager hack, the rest is standard pager_link code.

  if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
    $parameters['page'] = $new_page;
  }
  $query = array();  
  if (count($parameters)) {
    $query[] = drupal_query_string_encode($parameters, array());
  }
  $querystring = pager_get_querystring();
  if ($querystring != '') {
    $query[] = $querystring;
  }

  // Set each pager link title
  if (!isset($attributes['title'])) {
    static $titles = NULL;
    if (!isset($titles)) {
      $titles = array(
        t('« first') => t('Go to first page'),
        t('‹ previous') => t('Go to previous page'),
        t('next ›') => t('Go to next page'),
        t('last »') => t('Go to last page'),
      );
    }
    if (isset($titles[$text])) {
      $attributes['title'] = $titles[$text];
    }
    else if (is_numeric($text)) {
      $attributes['title'] = t('Go to page @number', array('@number' => $text));
    }
  }

  return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL));
}