Work with Pathauto

lomz - November 23, 2008 - 07:19
Project:Tagadelic
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:metawake
Status:needs review
Description

Could tagadelic be made working with pathauto?
So that we could avoid this kind of links: /tagadelic/chunk/15 and instead be able to customize this easiely

#1

metawake - October 7, 2009 - 18:09
Assigned to:Anonymous» metawake
Status:active» needs review

Here is how I've made tagadelic work with Pathauto. I've modified theme_tagadelic_weighted().

It now pulls aliases from url_alias table and displays them in links, so that
we see not plain 'term/5' links, but more meaningful aliased links. The code also checks if both pathauto and related alias exist.
At last, I can see transliterated tag names on my site in tagadelic links!

Would like to know other developer's opinion as to whether approve this patch or not.

function theme_tagadelic_weighted($terms) {
  $output = '';

  foreach ($terms as $term) {
   
  $link = taxonomy_term_path($term);

  if (module_exists('pathauto')) {
      $alias_data =   _pathauto_existing_alias_data($link);
      $new_link = $alias_data['old_alias'];
      if ($new_link) $link = $new_link;

    }
    $output .= l($term->name, $link, array('attributes' => array('class' => "tagadelic level$term->weight", 'rel' => 'tag'))) ." \n";
  }
  return $output;
}

 
 

Drupal is a registered trademark of Dries Buytaert.