I have a node content type that requires users to choose two vocabulary terms from before submitting. How do I setup pathauto to take these two vocabulary terms and use them as the url?

Automated Alias Settings Picture

I have two vocabularies (Cities and Categories) that the user has to pick from. I want the url to take the first term and then the second term. For example: http://example.com/nashville/auto_parts .

Any ideas?

Comments

tdave00’s picture

Bump.

Summit’s picture

Subscribing, same question. I can only figure it out from one vocabulary.
greetings, Martijn

trebuchet77’s picture

I'm still looking for this solution, if anyone has it, or a link to it. It would be much appreciated!

It would be right proper to be able to insert ["myVocab":termpath-raw]
as a pattern instead of having to use the primary one.

Or even better would be the functionality to have a URL alias for each term in the termpath for use in PathAuto or any other module. I guess that's a feature request, eh?

Anyone with any light on this?

Thanks

-Tre

Deciphered’s picture

You'll find more information on the status of this feature request at: http://drupal.org/node/185446

Cheers,
Deciphered.

fidot’s picture

I also hit this problem where I had a vocabulary of towns / venues and another of labels / bands.

I wanted to create a "gigs" node with a url containing town/venue/band

The venue and band are selected from the two taxonomies as part of the node creation/update.

The following workaround works for me:-

Using the Automatic Nodetitles module (http://drupal.org/project/auto_nodetitle), I set the option "Automatically generate the title and hide the title field" within "Automatic title generation"

This option allows pre-population of the node title.

I also checked the "Evaluate PHP in pattern" option and inserted the following code in the "Pattern for the title" textarea.

$result = "";
$node = node_load(arg(1));
$vid = 1;  // Labels and Artists
if($node->taxonomy){
  $term = taxonomy_node_get_terms_by_vocabulary($node, $vid);
  foreach($term as $t) { $terms[] = $t->name; }
  $result = implode('+',$terms) ;
} 
return $result;

This code populates the title field with terms from taxonomy 1 (Labels & Artists) which is the more heavily weighted taxonomy in my site.

Then, I set the "Node path settings" within "URL aliases" for the relevant node type to "gigs/[termpath-raw]/[title-raw]".

As the title contains terms from the heavier taxonomy, the final path contains terms from both taxonomies.

Obviously the PHP code used in my example could reference many taxonomies, but this method does rely on not needing the node title for anything else.

HTH
Terry

OneTwoTait’s picture

Cool idea. In my case unfortunately, I need the node titles though.

I think this feature shouldn't be so hard to do. I mean, I have a module that does it already. It just doesn't work all the time and I don't know PHP or other programming at all. The person that made this module for me did it quite quickly (like, a day), but then disappeared instead of debugging it so it works all the time.

fidot’s picture