1

I have a view where I am displaying nodes using row style Node. I want to edit the way the Node row style.

I edited the file /modules/node/node.tpl.php and commented the line

print $picture;

just for testing.

I was expecting that the picture field of each node would vanish. But I saw no change in the view display. Why is this?

6
  • have you flushed the cache ? Nov 24, 2012 at 10:36
  • No success even after flushing cache.
    – Shuaib
    Nov 24, 2012 at 10:45
  • Is your view set to display fields or content?
    – Clive
    Nov 24, 2012 at 11:43
  • It is set to display Content
    – Shuaib
    Nov 24, 2012 at 11:55
  • 2
    Just to clarify...$picture refers to the user picture, not an image field, in the node template file. Are you saying the user picture is still shown even after you remove that line?
    – Clive
    Nov 24, 2012 at 12:42

1 Answer 1

2

The documentation for the plugin says:

The node row style will display each item of the view through Drupal's standard node_view() function. Views has very little control over this output, except for the options you see. You can choose from different Build modes. By default there are "Teaser" and "Full node". You can also decide if you want to "Display links" and/or "Display node comments".

Because the output is run through the standard node template mechanism (typically node.tpl.php or a variant thereof), any decisions about what is output may be done there.

Views does add an extra 'suggestion' to the list of possible node templates: node-view-VIEWNAME.tpl.php—you may use this to theme a node specifically for the view. This can be handy for creating very small teasers and the like.

The template file could be different from node.tpl.php if there are other template files suggested for the content type, or a node in particular; the Views module itself suggests a template file whose name depends from the view name. Then, between the node.tpl.php defined from the Node module, and the same file defined from the theme, the latter is the used one.

The rendering method use for that plugin is views_plugin_row::render(), which contains the following code.

return theme($this->theme_functions(), $this->view, $this->options, $row, isset($this->field_alias) ? $this->field_alias : '');

With Drupal 7, the method is views_plugin_row_node_view::render(), which contains the following code.

  if (isset($this->nodes[$row->{$this->field_alias}])) {
    $node = $this->nodes[$row->{$this->field_alias}];
    $node->view = $this->view;
    $build = node_view($node, $this->options['view_mode']);

    return drupal_render($build);
  }

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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