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.

Comments

imclean’s picture

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

imclean’s picture

StatusFileSize
new1.33 KB

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

Should probably check that an array is returned:

  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.

preetinder’s picture

Thank you :)

Works for me.

CT is really a good module.

gg4’s picture

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

imclean’s picture

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

gg4’s picture

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.

sime’s picture

Here is an updated patch.

This is extremely useful for filefield_paths module.

YK85’s picture

subscribing - would you kindly give an example of how this token will look?

sime’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.13 KB

So I've confirmed the approach works. I've just added in a check to make sure there is at least one tid. RTBC

yaz085 a screenshot of what exactly?

gg4’s picture

StatusFileSize
new3.25 KB
gg4’s picture

StatusFileSize
new3.85 KB

slightly updated.

magnus’s picture

Thanks! I used patch in comment #9 and this works really great.

gordon’s picture

subscribing

dave reid’s picture

Andrew Gorokhovets’s picture

subscribing

gg4’s picture

Thoughts on getting this to work with the latest Token and Pathauto devs?

::

gg4’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.53 KB
gg4’s picture

StatusFileSize
new4.88 KB

New patch.

magnus’s picture

Status: Needs review » Reviewed & tested by the community

I could't get #17 to work and hadn't the time to investigate further. The patch in #18 works great. Thanks a lot!

betsonthomas’s picture

subscribing

splash112’s picture

This seems a very good feature. Any idea why it's not in dev?

splash112’s picture

Just to expand on what I want to do.
I need to organise my sites catalog and products with term-paths. The standard Taxonomy/Pathauto solution has big troubles with multiple terms on 1 node.

I thought to be clever and use Content Taxonomy with 2 fields, 1 main field with 1 required term for a pathauto term/path and one for extra terms (multiple). Both should sync with the core Taxonomy module for breadcrumbs, Views and things.

Any idea if this would work with this patch?

splash112’s picture

Tested the patch against latest dev. Seems to be working flawless except for some whitespace BS from Git. Nothing really to worry about.

RTBC

dbassendine’s picture

Works well for me. It would be great to see this rolled in, it's a very useful feature.