Send to a Friend
Drupal tokens tutorial/help?
If you’re too lazy to read through this question, could you just direct me to some site where they have posted a tutorial on using the ‘token’ module’s string replacement functions when creating a module. Or atleast some sample code, with sample calls to the token_replace function?
I’m creating a form alter module in drupal, which will alter the node addition form to set some default values in the form’s fields. Now I have got the code to set the default value working as such:
$form[‘locations’][’#location_settings’][‘form’][‘fields’][‘name’][‘default’] = ‘Neil’;
Now in place of the string ‘Neil’, I want to get the text replacements of tokens, specifically, I wanna retrieve the uid of the author of the node, then look up a detail of his (his location). What would the token replacement string be? something like… token_replace($form[‘uid’][‘locations’][’#default_value’][‘city’]);
right? and I’m not sure what kinda value I have to pass for the $object param.
Anyhow, this is giving me some parse errors, and frankly, I’m astonished by the complete lack of documentation on how to use tokens, and the syntax.