0

I have a view with 2 fields - one is another view, one is a node field. I do not want to display the parent view header when the inner view result set is empty and the node field does not have a value. "Display even if view has no result" is unchecked on the header settings but does not work because the parent view always has a result regardless of the presence of a value.

I am trying to add a PHP filter that checks for both criteria. I am running into the old issue that the $row object only contains node ids, but the $data object does not seem to work here, either. It only contains two properties, the view and the entity type of the attribute (called field_data_field_electronics_description_node_entity_type in this case).

So, this does not work for my filter code because the entity type is always set, even when the value is empty:

if ($row->view != NULL || 
   $data->field_data_field_electronics_description_node_entity_type != "" )   
{
   return FALSE;
}
else return TRUE;

This does not work because field_electronics_description always contains the node id, regardless of the presence of a value:

if ($row->view != NULL || $row->field_electronics_description != "" ) {

I don't see anything else in the $data object in devel that I could use. How can I suppress the parent view display?

  • Note to self: must load node again, for some weird reason. Millions of Drupal users have spent 10s of millions of person hours to figure this out. drupal.org/node/1222448 – cdonner Jun 24 '15 at 3:32
0

The answer was - the node fields are not available and you have to reload the node, like so:

$nodef = node_load($data->nid);
$el = $nodef->field_electronics_description[und][0][value];

if ($row->view != NULL ||  $el != NULL) {
   return FALSE;
}
else return TRUE;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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