Search code examples
templatesdrupal-7blocknodes

Drupal 7 get nid in node view block tpl


I had to modify a view block tpl (views-view-[xyz]--block.tpl.php)

In this block, only one node is displayed (the latest of it's type). I have to get its node id (nid) in this file. How can I proceed?

I don't find anything about it on the Internet.

Thanks


Solution

  • For those who will have the same issue here are some solutions:

    You can use entity view in your view block instead of the fields. Then in the hook_node_view you will have easy acces to the nid.

    Or you can use the fields and add the fiels "Nid" and via the views-view-field.tpl.php ou have direct access to the nid.