Hi there,
I want to create a custom file directory token from the first two letters of the filename,
i.e. /w/e/welcome-gif
If I add tokens to filefield.token.inc, it works fine. Something like this:
$tokens['filefield-a'] = substr(check_plain($item['filename'], 0 ,1);
$tokens['filefield-b'] = substr(check_plain($item['filename'], 1 ,1);
However, I want to put this in my own module. I'm following the tokenstarter module. It's all very easy to do,
BUT, my tokens aren't recognized.
function my_tokens_token_list($type = 'all') {
The $type here is always "user" or "node", but never "field" or "all". It appears my custom tokens aren't available to filefields, they don't show up.
So what's the trick here? How to create custom filefield tokens? Why does the same code work in filefield.token.inc, but not in a custom module?
Comments
Comment #1
quicksketchI suggest you look at FileField Tokens and see how it creates tokens based on the file and node information.
Comment #2
quicksketchComment #3
chrisdawson commentedI'm having the same problem. quicksketch, FileField Tokens doesn't seem to exist any longer.
Any other modules which extend FileField's token list?
At the moment I'm having to mod filefield.token.inc to use my custom tokens :-(
Would really appreciate some assistance!
Comment #4
quicksketchSorry it's FileField Paths, not tokens. See these modules:
http://drupal.org/project/filefield_paths
http://drupal.org/project/imagefield_tokens