Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal Token Replacement in Template File

Can I use token replacements in Drupal template files? I'm trying this:

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

But it's not working. How can i properly use token replacements in my node.tpl.php template?

like image 468
hanleyhansen Avatar asked Aug 02 '12 17:08

hanleyhansen


1 Answers

Got it!! This worked for me:

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

You have to pass the $node to the token_replace() function and you will then get your desired results. Hope this helps someone!

like image 129
hanleyhansen Avatar answered Oct 26 '22 13:10

hanleyhansen