0

Basically I want to create a php code in my template (views-view-field--body.tpl.php) that would say the following...

if [body] print [node_view] endif

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
canintex
  • 638
  • 1
  • 7
  • 21
  • 3
    Please clarify your question. Do you mean you want to print the full node if there's any value in the field "body"? – Aaron Oct 31 '09 at 03:05
  • No I only want to print the (Node: Link) if there is content in the (Node: Body). – canintex Nov 04 '09 at 17:36

2 Answers2

0

Off the top of my head and at first look it seems like you are using fields. If it is so, if you look at views-view-field.tpl.php, the comments specify:

  Variables available:
  - $view: The view object
  - $field: The field handler object that can process the input
  - $row: The raw SQL result that can be used
  - $output: The processed output that will normally be used.

When fetching output from the $row, this construct should be used: $data = $row->{$field->field_alias}

thus you could do something like

if ($row->{$field->body}) { 
  print $row->{$field->view_node}
}
zerolab
  • 826
  • 8
  • 17
0

What I did to do this was download Views Custom Field and then use this code for the value:

<?php 
if ($data->node_revisions_body) { 
 echo '<a href="/node/' . $data->nid .'">view</a>';
}
?>
canintex
  • 638
  • 1
  • 7
  • 21