1

What is the proper way to store token replacements in a variable? Or should i even bother and call them directly?

Things like:

$author_uid = [node:author:uid];
$name = [node:title];
$picture = [node:field-image-upload:file];
$link = [node:url];

Are giving me an error:

PHP Parse error:  syntax error, unexpected ':'

Am i doing something wrong?

Also in regards to this line:

$picture = [node:field-image-upload:file];

What I'm really trying to get is the url link to that image file. How can I do this with a token?

2

Token are a kind of meta language that needs to be processed to get the proper value. For it, you should send your token into a process function called token_replace.

Here is an example :

$author_uid = token_replace('[node:author:uid]');

Check this documentation page for further informations

1
  • Note that for hardcoded tokens, this doesn't make much sense, just access the value ($node->uid in this case), directly. token_replace() is useful for configurable strings, like mail subjects/bodies and other kinds of messages that users can configure. – Berdir Aug 2 '12 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.