0
votes

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

2
Please clarify your question. Do you mean you want to print the full node if there's any value in the field "body"? - Aaron
No I only want to print the (Node: Link) if there is content in the (Node: Body). - canintex

2 Answers

0
votes

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}
}
0
votes

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>';
}
?>