Hello,

I'd like to get a taxonomy term's parent term so it could it be used in Custom Breadcrumbs for Views. At #628796: Breadcrumb setting for: Home > Taxonomy Parent Term > Taxonomy Child Term a possiblity of developing a new token for this is mentioned, unfortunately I'm not much of a coder so a bit of help would be greatly appreciated...

Comments

Version:6.x-1.12» 6.x-1.x-dev
Category:support» feature

+1 for this token! to use it in a page-title.
I would like the taxonomy parent term and top term in the taxonomy tokens, it's missing right now.

greetings, Martijn

I have a similar requirement. I'd like to see a list of all parent terms in situations where there are multiple parents. By the way comment #9 here: http://drupal.org/node/654766 seems to be seeking to do something similar

+1 for this token for use in page titles

OK, I have written some code that worked for me although Im sure it requires a whole host of other changes to make it more accurate or something...

In token/token_taxonomy.inc I have made the following changes...

      $values['tid'] = $category->tid;
      $values['cat'] = check_plain($category->name);

has changed to
      $values['tid'] = $category->tid;
      $parents = taxonomy_get_parents($category->tid);
      $parents = array_shift($parents);
      $parent = $parents->name;
      $values['parent-term'] = $parent;
      $values['cat'] = check_plain($category->name);

and further down...

    $tokens['taxonomy']['tid'] = t('The id number of the category.');

has changed to...
    $tokens['taxonomy']['tid'] = t('The id number of the category.');
    $tokens['taxonomy']['parent-term'] = t('The term name of the parent of the page term.');

Thanks Willeaton, that gets [parent-term] to show up on my admin/help/token page, but not in my custom breadcrumbs page where I can use tokens to create breadcrumbs. Any ideas why not? When I put [parent-term] in the custom breadcrumbs, it shows me [parent-term] not any token value.

Sorry, I don't really understand how tokens work. I just took the existing file, added a few lines and the new token appeared for me in the nodewords module configuration page.

+1

i guess everyone knows, but never edit the code of a contrib. or core module, unless if you are building a patch and you really know what you are doing.

Instead, for this case you can create custom tokens in different ways: