Retrieve node information in VIEWS template(s) I have figured out I need to override two templates:


views-view-fields.tpl.php
views-view-unformatted.tpl.php


Basically my node has an "align" property which I need to access in both templates to properly generate the expected markup.

&lt;?php echo '&lt;pre&gt;'; print_r(get_defined_vars()); exit; ?&gt;


Using this I can see I have a monster of a structure at my disposal but the I am nervous about traversing such a structure as the slightest change to it's arrangment means my template(s) would break!!!

Ideally I would like to implement a preprocessor such as:

How can I add variables from a preprocessor function to be used in an unformatted view template?

Basically add the "align" value from the node to a simple variable which I can then access and check inside both templates listed above...

Suggestions???
You can use hook_preprocess(&amp;$variables, $hook)to find out which hook you have to react on, in your case it should be hook_preprocess_views_view_fields() and hook_preprocess_views_view_unformatted().

Next you have to find a way to access the node object. If your view is node based, then there should be an nid somewhere in the variables array. Don't be afraid to dif into the $variables array. You can use dpm (devel module) or print_ror whatever you're comfortable with. You can't really break anything without manipulating the array.