Replacing a Drupal token in a template file

Can I use token replacements in Drupal template files? I try this:

$author_uid = "[node:author:uid]"; $nid = "[node:nid]"; 

But it does not work. How can I use token replacements correctly in my node.tpl.php template?

+6
source share
1 answer

Got! This worked for me:

 $author_uid = token_replace('[node:author:uid]', array('node' => $node)); $nid = token_replace('[node:nid]', array('node' => $node)); 

You must pass $ node token_replace () functions, after which you will get the desired results. Hope this helps someone!

+12
source

Source: https://habr.com/ru/post/921972/


All Articles