With module enabled and using the hook_init() method, pager links (first, prev, 1 ,2 ,3 ,4 etc... next, last) on list pages lose their URL aliasing.

For example, say I was on /items/widgets with the TFA module enabled, and with more nodes than could fit in that page being listed.
Were I to hover over the page "4" link, I'd see
/taxonomy/terms/4/all?page=3
rather than
/items/widgets?page=3

The aliased links work, it's just that they're not being used in the pagination. I can type in the /items/widgets?page=3 link manually and get page 4 of a listing of nodes, just as if I were to go to /taxonomy/terms/4/all?page=3

I have tried the hook_link_alter option and it flat out doesn't work for me on Drupal 5.2.

Any ideas?

Comments

c_kais’s picture

Fixed, I think.
I had to theme the pager_link function as follows:


function phptemplate_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
  $page = isset($_GET['page']) ? $_GET['page'] : '';
  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));
    }
  }

  if (module_exists('taxonomy_forceall')) {
  	return l($text, preg_replace('/\/all$/','',$_GET['q']), $attributes, count($query) ? implode('&', $query) : NULL);
  } else {
  	return l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL);
  }
}

The only change is in the return...
If Taxonomy Forceall is on, strip the "/all" from the url before looking it up in the url alias table (which is what the l() function eventually does). Of course, none of the forced all urls will be in the url alias table because the TFA module tacks on the all...

grah’s picture

thanks kaiser. your solution works.

i'm aliasing rss feeds and those have also broken down due to TFA. ;/

Z2222’s picture

Thanks...
This solution works, but it's still broken in the module.

pomliane’s picture

Status: Active » Closed (won't fix)

This version of Taxonomy Force All is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.