Download & Extend

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

Project:Content Taxonomy
Version:6.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

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

Comments

#1

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

#2

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

Thank you :)

Works for me.

CT is really a good module.

#4

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

#5

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

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.

#7

Here is an updated patch.

This is extremely useful for filefield_paths module.

AttachmentSize
content_taxonomy-termpath-tokens.420240.patch 2.07 KB

#8

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

#9

Status:needs review» reviewed & tested by the community

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?

AttachmentSize
content_taxonomy-termpath-tokens.420240-2.patch 2.13 KB

#10

AttachmentSize
token_cck_term_path.zip 3.25 KB

#11

slightly updated.

AttachmentSize
token_cck_term_path-2.zip 3.85 KB

#12

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

#13

subscribing

#14

#15

subscribing

#16

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

::

#17

Status:reviewed & tested by the community» needs review

Also requires commit of #932680: content_token_values() does not pass along $options to the called hook_token_values().

::

AttachmentSize
content_taxonomy.token_.inc-420240-17.patch 3.53 KB

#18

New patch.

AttachmentSize
content_taxonomy-420240-18.patch 4.88 KB

#19

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!

#20

subscribing

#21

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

#22

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?

#23

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

RTBC

#24

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

nobody click here