I have a Vocabulary called Artists, which has a list of artists that are in the post.

ie: if I post a DJ Set by Richie Hawtin, I'd enter Richie Hawtin into the Artist field.

At the bottom of the posts, right now "Richie Hawtin" links to taxonmy/term/42

How can I change this so it'd link to artist/info/42 instead?

Comments

ThatPerson’s picture

Drupal has a built-in module for aliasing paths: the Path module. Enable it and under URL Aliases create an alias from "taxonmy/term/42" to "artist/info/42".

But... it'll be hard to create aliases for all of your terms. Well, there is an automatic path alias module called "Pathauto"!

http://drupal.org/project/Pathauto - The Pathauto module will allow you to define a set of rules for automatically aliasing your paths.

kaniz’s picture

  $vocabularies = taxonomy_get_vocabularies();
  foreach($vocabularies as $vocabulary) {
    if ($vocabularies) {
      $terms = taxonomy_node_get_terms_by_vocabulary($node->nid, $vocabulary->vid);
      $termslist = '';
      if ($terms) {
        print '<div class="terms">' . $vocabulary->name . ': ';
        foreach ($terms as $term) 
	{
		if($vocabulary->vid = 3)
		{
			$termslist = $termslist.l($term->name, 'artist/info/'.$term->tid) . ' | ';
		}
		else
		{
			$termslist = $termslist.l($term->name, 'taxonomy/term/'.$term->tid) . ' | ';
		}
        }
      print trim ($termslist," |").'</div>';
      }

    }
  }

Just added the if vid=3 bit, and does excatly what I wanted to do.

nancydru’s picture

Thatperson: Your solution is fine unless this is being done for a module. URL Aliases aren't used to enter a module (menu call back).

Kaniz: where did you find this, and where/how are you using it? This may help me out on a problem.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

kaniz’s picture

note: should be vid==3 not vid=3, been programming in VB.NET for school too much the past while :)

Found this bit of code here: sort taxonony links ($terms) by vocabulary ($vid), and just added the if statement to check for the vocab ID.

This solution will be useful, as I'll have a few different terms that I'll want to link too differently. I put this into the node.tpl instead of having print $terms

You might also find this post helpful.

nancydru’s picture

When coding a module, as I am, it is best to not mess with template code because you never know which template the eventual user will have.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database