0

I want to print out a script from facebook on a specific node page in my html.tpl.php file. What is the best way of doing this? looking for nid? I need some kind of a if statement...

thanks

1

a hacky solution in html.tpl.php could be like this:

$node = node_load(arg(1));
echo $node->nid;

You'll want to check for the existence of $node and such to avoid errors.

You could also create your own node template: node--123.tpl.php

You could also use the HOOK_preprocess_page() function to check for the node ID.

  • Use menu_get_object(), not node_load(). – kiamlaluno Oct 7 '15 at 16:21
  • thanks for the help but how would I write a good if statment? – user2945872 Oct 8 '15 at 7:23
  • @user2945872 I'm afraid that's a bit beyond the scope of this board. why don't you try one yourself and if you get stuck you can post a specific question (including your code) and ask for help – user5482 Oct 8 '15 at 13:11

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