"termpath" token support for hierarchical vocabularies for use with Pathauto

imclean - April 1, 2009 - 05:56
Project:Content Taxonomy
Version:6.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

CT is a very handy module, thanks!

Here's a quick patch to add the "termpath" token support to the first vocabulary of the node for use with Pathauto. It really only make sense with hierarchical vocabularies.

AttachmentSize
content-taxonomy-termpath-tokens.patch1.12 KB

#1

imclean - April 1, 2009 - 06:08

Correction, that should be: "Here's a quick patch to add the "termpath" token support to the first term of the vocabulary".

#2

imclean - April 1, 2009 - 23:34

Added -raw support. Also works with FileField to some extent.

Should probably check that an array is returned:

<?php
 
if (is_array($parents)) {
      foreach (
$parents as $parent) {
       
$pnames[] = check_plain($parent->name);
      }
      if (
is_array($pnames)) {
       
$tokens['termpath-raw'] = implode('/',array_reverse($pnames));
       
$tokens['termpath'] = check_plain($tokens['termpath-raw']);
      }
  }
?>

The above is not included in the patch. Will see what else needs fixing before I upload yet another one.

AttachmentSize
content-taxonomy-termpath-tokens.patch 1.33 KB

#3

tony31 - July 2, 2009 - 18:21

Thank you :)

Works for me.

CT is really a good module.

#4

_double - September 4, 2009 - 20:48

any updates on this patch -- doesnt want to apply.

#5

imclean - September 9, 2009 - 00:15

It's not something I'll be maintaining. If the functions the patch provides haven't been included in the dev version then they probably never will be.

The patch is only a few lines so you could have a look at it and add them yourself. The file to look for is content_taxonomy.token.inc

#6

_double - September 9, 2009 - 20:26

Thanks for the reply. I did go ahead and just add the code myself. I really wish this would get included into the module — very useful.

 
 

Drupal is a registered trademark of Dries Buytaert.