I've created a view block with views3. When I attach the views block to a node, I want to know if the node is sticky and if the content type is "lodging". If the criteria are met, do not display view result.
In the views filter (php field) I've created the following code.
if (arg(0) == 'node') {
$nid = arg(1);
$node = node_load($nid); // get node id
}
$sticky_status = $node->sticky; // get sticky status
$node_type = $node->type; // get node type
if ($sticky_status == '1' && $node_type == 'lodging') // condition if sticky is 1 (active) and node type is "lodging"
{
$view->result = null; // do not display views
}
The code is working fine and I get the desired result, however I also get the following warning message:
Warning: Invalid argument supplied for foreach() in views_php_handler_filter->php_post_execute() (line 84 of /var/www/html/planetlodge/sites/all/modules/views_php/plugins/views/views_php_handler_filter.inc).
Warning: array_slice() expects parameter 1 to be array, null given in views_php_plugin_pager->post_execute() (line 46 of /var/www/html/planetlodge/sites/all/modules/views_php/plugins/views/views_php_plugin_pager.inc).
Warning: array_values() expects parameter 1 to be array, null given in view->execute() (line 1155 of /var/www/html/planetlodge/sites/all/modules/views/includes/view.inc).
Where is the error in the code ?