I have a custom content type (hand-coded module, no CCK), and would like to use one of the fields it defines as a part of the url alias. Just entering the field name in the pattern for the content type does no good - I get the following error:

You are using the token [page_key] which is not valid within the scope of tokens where you are using it.

I looked around but can't find an answer to this, though I would have supposed it to be a (more or less) frequent situation.

Thanks for your help!

Comments

greggles’s picture

hello solaas -

Essentially what you need to do is implement the hook_token_list and hook_token_values. Take a look at the token API.txt file for more details.

greggles’s picture

And of course let me know if you need more guidance.

solaas’s picture

Thanks a lot, greggles.

I found in my situation it was a lot simpler to just call path_set_alias() on hook_insert - your module is wonderful but kinda overkill for me at the moment...

Hope to see ya again soon in Buenos Aires!

greggles’s picture

Status: Active » Closed (fixed)

sure.

doublejosh’s picture

Hey, I'm using Feed API to create feeds and feed-items. I'd like to use pathauto to create alias for feed items and have the parent feed in that path i.e. www.mydomain.com/feeds/[feed-title]/[feed-item-title-raw].

I've read through the Token API so I see how to create a custom token BUT I'm not sure where to place that function.

Also, it's going to be a little fun to traverse up the nid chain to get that parent title, unless I can reveal it in the feed item (still have to put devel on this site.)

Thanks for any help!