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?
If you want to store a token in a variable, you should write $author_uid = "[node:author:uid]";
Note that the token is just a string.
As noted in the documentation for token.inc
, the token system is an...
API functions for replacing placeholders in text with meaningful values.
If you want the URL Link to the image file, you could do:
$picture = token_replace('[node:field-image-upload:file]', array('node' => $node));
Note that you would need to already have the $node
object to pass into the token replacement function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With