Hello guys !!!
In first place I'd like to congratulete for the very good work in pathauto module.

I tell you a common case where you have serveral taxonomies and only you can use one in url path using 2.X version of Pathauto.

Example: You have cars.

Ferrary , Sport Cars, Luxury Cars , Testarrosa

I'd like to autogenerate a path as :

mysite/cars/sport_cars/luxury_cars/ferrary/testarrosa

where :

Testarrosa is the name of the node and all others terms are categories :

[vehicles] --> Cars , Trains , ...
[use] --> Sport , Family
[economy] --> Luxury , Cheap , Normal
[brand] --> Ferrary , Bmw , ...

The correct path desired path would be :

[vehicles][use][economy][brand]

where all terms are names of categories.

What do you think of this issue ?

Best Regards.

Ricardo Cabello Torres.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Title: Needed full category path to full categorized nodes. » tokens for each vocabulary
Project: Pathauto » Token
Version: 5.x-2.x-dev » 5.x-1.x-dev
Status: Active » Postponed

Thanks for the idea!

My preference would be for this to work something like [term:vid] and [termpath:vid] where "vid" is the vocabulary ID for the vocabulary that you want to use.

I think it's a pretty reasonable idea, but don't plan to work on it soon (someone else certainly could, of course). Hence I set the status to postponed.

moshe weitzman’s picture

for the record, this is what I need for a current client. I would only want the top level term from a specific vocab something like [term:vid:depth] appeals to me. or maybe thats no needed since we would always return depth=0 term if thats specified.

greggles’s picture

Eaton has discussed how this is currently possible in the tokens group. In general, though, it's a bit of a performance concern and the whole idea of modifiers like vid and depth doesn't exist right now outside of field_* for cck fields.

The performance concern and the modifiers would be fixed by the work proposed for tokens2 (by eaton and/or fago) but nobody has started on it yet afaik.

s.Daniel’s picture

Read every pretty much everything in the token group but couldn't quite figure out which post you ment.
Please post the link.

greggles’s picture

Some bad html on comment #3 caused the link to show up incorrectly - it should be http://groups.drupal.org/node/6675

(I also edited the comment to fix that).

doc2@drupalfr.org’s picture

Greg says in #3 that "Eaton has discussed how this is currently possible in the tokens group."

Well, it seems to me that it's far beyond the reach of many drupalers... unfortunately...

This would be so useful... I hope that improvements for d6 versions will be backported if nothing is done soon on this feature request...

Michelle’s picture

I normally lothe "subscribe" posts but, since my issue got duped in favor of this one, I need to get this one in my tracker, too.

Michelle

Summit’s picture

Hi,
Very much in favor of token support for terms chosen from a vocabulary.
The workaround: http://drupal.org/node/215751#comment-713270 is no option for me, because then my taxonomy context menu's are not ok anymore..all terms are through each other instead of nicely organised as it is now.
Thanks for considering this!
Greetings,
Martijn

laken’s picture

+1 for this feature! It's easy to imagine a great many scenarios where the ability to replace tokens from specific vocabularies is necessary. The current capability (can only pull the lowest weighted term from lowest weighted vocabulary) is only useful in the simplest cases. I can't help code this, but I will gladly test any patches!

btw, I, too, couldn't find the "how this is currently possible" discussion referenced in #3 above...

EvanDonovan’s picture

+1 for this feature also!

Is there any current development on Tokens2 (as referenced in #3) or is it all on the D6 port of Tokens 1?

Is the "how this is currently possible" description where it says:

"The cck code does it automatically declaring new tokens as new fields are added to they system. I use it with no "manual" intervention necessary.

The hook_token_list/hook_token_values for vocabs could work the same way, right? getting a list of all vocabs and declaring tokens by looping over that list."

If I have time I'll look into how that would work, although it sounds like it might slow things down a lot if you have multiple vocabs.

pessimizer’s picture

FileSize
759 bytes

Until I tried to register, I had no idea I had an account here :)

I desperately need this mod so I don't get buried in a content type avalanche. I'm creating a site in Drupal for the first time as an intranet at my company, and being pretty conservative in my sense of organization, believe that a new content type should be reserved solely for a piece of data that requires a different combination of fields. If they look the same, they should be the same content type, and differentiated by taxonomy only. At this point, I can't really do this because access and rights to creation are assigned per content type, and 'required' is a characteristic of the vocabulary rather than the content type (throwing hard to explain monkey wrenches in a lot of my plans!) I found this page while trying to do something that I assumed would be easy, but has never been needed before, I guess.

I'm looking for a module or something that would make this simple and bulletproof, but for now, I'm using a hack to token_node.inc (in 5.x-1.11) Keep in mind that I don't know much about Drupal, and I think php is an abortion, so I don't really know much about that either - but the change works. It only adds the recognition of the vocabulary tokens to node_token_values() and not node_token_list(), so pathauto will squawk if you use them, but react properly when actually creating the urls.

Restrictions: all vocabulary names must be entered in lower-case (e.g. [vehicles]), and will be replaced in lower case, and even the '-raw's will be converted to lowercase (though you can change that easily if you're in the mood.) The new tokens ONLY act on required vocabularies, and will be ignored if the vocabulary is not required. Only the lightest term is taken.

This is not bulletproof, and not graceful, but I thought I'd share.

edit: The two reasons why I didn't add code to node_token_list() were 1) because, while only a couple of vocabularies may apply to any particular node, there may be an assload on the entire site; the token list is already cluttered with the cck tokens, so I didn't want to clutter it with a massive number of tokens that you can't even use, and 2) because I didn't want anybody doing it here that didn't know exactly what they were doing.

*** token_node.inc	2008-04-08 21:17:55.000000000 -0500
--- token_nodenew.inc	2008-08-27 11:45:23.000000000 -0500
***************
*** 143,148 ****
--- 143,155 ----
          $values['vocab-id'] = '';
        }
  
+ 	  $reqvocs = array_filter(taxonomy_get_vocabularies($node->type), create_function('$avoc','return $avoc->required == 1;'));
+ 	  foreach($reqvocs as $tokenvoc){
+ 		$lightterm = strtolower(db_result(db_query("SELECT t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight LIMIT 1", $tokenvoc->vid, $object->nid)));
+ 		$values[strtolower($tokenvoc->name).'-raw'] = $lightterm;
+ 		$values[strtolower($tokenvoc->name)] = check_plain($lightterm);
+ 	  }
+ 	  
        break;
    }
    
pessimizer’s picture

Status: Postponed » Needs work
greggles’s picture

Status: Needs work » Postponed

The approach here is a dead end for token core. It's great to have example code and may be useful to other people, but this issue is postponed until 6.x-2.x-dev of token is created due to performance issues. If you need to subscribe, fine. But don't change the status inappropriately.

pessimizer’s picture

sorry, greggles. Didn't know the protocol - of course you've already made that clear. People will be able to find the patch without any change in the status, because every thread about this subject leads to this one. The only reason I changed the status is because I was afraid I had committed a faux pas by posting a patch and not changing the status :)

I can't even see how this patch could be fit into token the way it is structured now, anyway. The patch is only offered for people who need the functionality on a particular project and nothing else will do.

greggles’s picture

Ah, ok. Well, it is a pretty subtle different I guess when it's best to change to patch (something) and when to just leave as postponed. Thanks for the explanation.

Summit’s picture

+1 for getting a term per vocabulary for starters, I would very much like to have the possibility to get to every term assigned to a node through token.

What donation is needed to get this done for D5 AND D6 within 2008 scope?

Greetings,
Martijn

greggles’s picture

Driving this through to completion is not easy because it requires some fundamental reworking of the module. It would be 20-40 hours of work...

Summit’s picture

Well,

More than one people would love this enhancement as I can see on the duplicate feature requests. It would be great to be able to build a node as a template with inside node-body, node-title and may be different cck-field tokens to the terms which the node is assigned to. If this first would be only one term per vocabulary that would already be great!

Tokens and Rep-tags are integrated now in Drupal 6. Rep-tags has a tokens sub-module.
If it is hard work on the token part, may be the Rep-tags module can help? Greg did you spoke about this with the Reptag module (www.drupal.org/project/reptag) maintainer may be what the best way to get this feature request going?

Greetings,
Martijn

greggles’s picture

Yeah, I did.

1) We disagree on how to integrate the modules.
2) To do that right would also require the same 20-40 hours of refactoring/benchmarking that I mention.

Summit’s picture

Hi Greg,

I thought my usecase moreover and placed it as a forum-item http://drupal.org/node/338826.
Because it is related to this issue, but not completely. My request is getting to the url-aliased arguments from a deeper taxonomy term, say: www.example.com/India/Nepal/flight/himalaya (where India, Nepal, flight and himalaya are also taxonomy termnames.
May be these can be placed in tokens, without doing the term per vocabulary enhancements..

Hopefully it is also possible to have the url build by pathauto using terms from different vocabularies.
If this also needs the changes by you described I am still willing to sponsor some of the work.

My site is a e-development site (www.trekking-world.com), so I do not have a lot of money to get this done. On the other hand, may be you look at the usecase and have another opinion of getting this done.

Thanks again for your quick reply!
Greetings,
Martijn

Summit’s picture

Hi Greg,

Thought this over again this evening :)
I already have my terms through url-aliassing like in: www.example.com/India/Nepal/flight/himalaya.

Is there no possibility to strip the Termnames out of the url-alias to say.
urlalias-stripped 1 = India
urlalias-stripped 2 = Nepal
urlalias-stripped 3 = flight

Would this be possible with token?

greetings,
Martijn

jenlampton’s picture

Version: 5.x-1.x-dev » 6.x-1.11
FileSize
1.09 KB

I needed this top-term-in-a-specific-vocab token for my site so I wrote a little module for it. I know more robust versions of this functionality are coming shortly, but I needed it today :-) so...

I'm posting my token_vocab module here in case others need the same functionality, but I look forward to seeing (or helping with?) a more performance-savvy execution.

Notes: This module has not been tested with free tagging. This module is intended only as a starting point for those of you who are waiting for the new feature. This module is not "supported" and may still need a little love.

momper’s picture

subscribing

pankajshr_jpr’s picture

thanks .. subscribing

liquid06’s picture

@jenlampton Thank you for posting your module - seems to be working as intended. It's really helpful for those who need this functionality but don't have the expertise to make their own module or help with the token module. :)

nsputnik’s picture

subscribing

mr.andrey’s picture

Thanks for the module, it's exactly what I needed. We have videos categorized by teacher, type, focus, etc, and it's useful to have those in the URL.

Seems to work well.

marcushenningsen’s picture

Thanks for sharing your module, it works well.

OneTwoTait’s picture

Subscribing. I've been waiting for this feature for a long time. I had a module made for me that does this and will create URLs in the form "termfromvocab1/termfromvocab2" for however many configurations are enabled. It doesn't always work though and I don't know why... If somebody wants that, contact me and I'll send the module and show you the site it works on.

fidot’s picture

Please see workaround at http://drupal.org/node/338856#comment-2480182

HTH
Terry

mr.j’s picture

Another thanks for the patch at #22. It works fine without any code changes on 5.x too. You just need to edit the .info file, this is what I used:

name = Token for Vocabularies
description = Token for Vocabularies provides specific token replacements for the top term in each vocab
version = "5.x-1.0"
project = "token"
dependencies = token
Dave Reid’s picture

Title: tokens for each vocabulary » Provide tokens for each vocabulary
Version: 6.x-1.11 » 7.x-1.x-dev

Bumping to most recent version for new features.

Dave Reid’s picture

Status: Postponed » Closed (duplicate)

Merging this into #691078: Field tokens.

ShutterFreak’s picture

This somewhat "hidden" submodule (see #22) should be part of the Token module, or it should become a maintained module, as it did 90% of what I needed!

I'd like to suggest adding the "display version" of the taxonomy terms as well, instead of the tokenized-only representation.

Apart from that, kudos!

Olivier

rsevero’s picture

Inspired by the code from #22 I've created the Taxonomy Token module.

xjm’s picture

Tracking.

mr.j’s picture

Just a note on a bug I discovered in the code from #22.

It only provides aliases suitable for use in pathauto, not titles. eg 'vocab-term' vs 'Vocab Term'. The token for the name of the term is being cleaned and spaces replaced with hyphens when it should not be. This is no good for use as a breadcrumb title for example (I found it trying to use it with the custom breadcrumbs module).

So remove the call to _token_vocab_clean_name() on line 45 here:

$values['vocab-'.$name.'-term'] = check_plain(_token_vocab_clean_name($result['name']));

i.e.

$values['vocab-'.$name.'-term'] = check_plain($result['name']);