Hi
I use the Quicktabs module in combination with the DS suite and Views to add tabs in a node/content type. In a view I have set up 3 blocks that corresponds respectively to each tab and I use the contextual filter to fetch the right content for each tab.
Everything works fine so far.
But now, I have discovered that when I open a node that has no content in one or all of the tabs (because the corresponding block in the view doesn't produce any result) I get the message:

Notice: Undefined index: und in eval() (row 2 of C:\wamp\www\myproject\sites\all\modules\views\plugins\views_plugin_argument_default_php.inc(53) : eval()'d code).

I have set up an appropriate message in a Global text field for "No results behavior" in all three blocks in the view, but that does not help.

Any suggestions?

Comments

bjmagar1906’s picture

Page template can be looked into if the variables or block is being printed without checking it's existence. Setting "No results behavior" in the views may not work if the block or variable is being printed without checking if it is set.

Tommy_001’s picture

Solved (I think)
I added a snippet in the contextual filter to give the referenced nid a NULL value if indeed it is empty.
That way the evaulation work out since NULL is a value. By returning FALSE if the referenced value does not exist, the text from "No results behavior" is shown instead.
And this works fine :-). No more error messages.

My PHP skills are maybe not the best. This is what I wrote:

$node = menu_get_object();
if(empty($node->field_add_dcoument['und'][0]['nid'])){
	$node->field_add_document['und'][0]['nid'] = NULL;
	$val = FALSE;
}
else {
	$val = $node->field_add_document['und'][0]['nid'];
}
return $val; 

Is there a better way to write this?