I've create a view which displays all nodes with content type location
. This view renders the node using it's teaser display, which I've created a custom node--location--teaser.tpl.php
for.
In this template, I'm using entity_metadata_wrapper
as a cleaner way to theme values. My template begins with;
<?php
$nw = entity_metadata_wrapper('node', $node);
dpm($nw->value());
$name = $nw->label();
$phone = $nw->field_phone->value();
$fax = $nw->field_fax->value();
$address = $nw->field_address_plaintext->value();
?>
All of the stored variables used for themeing return values for the first node rendered by the view, but subsequent nodes only return a value for the $name
variable.
If I remove dpm($nw->value());
from line 3, I receive the appropriate values for all view results.
What is happening here? Why does dpm()
cause this to happen?
Update
I've moved this logic to a node preprocess function based on feedback from @Clive:
function _preprocess_location(&$vars) {
$nw = entity_metadata_wrapper('node', $vars['node']);
$vars['nw']['name'] = $nw->label();
$vars['nw']['image_url'] = file_create_url(image_style_path( 'location_thumbnail', $nw->field_image->value()['uri']));
$vars['nw']['phone'] = $nw->field_phone->value();
$vars['nw']['fax'] = $nw->field_fax->value();
$vars['nw']['address'] = $nw->field_address_plaintext->value();
}
If I add a dpm()
call anywhere in this function I encounter the same problem as described above.
eval
d, something in that might be causing the issue) - try moving the logic out to a preprocess function and see if you get the same results – Clive♦ Aug 26 at 18:25