I am struggling with where to start with the php code to add to the block visibility config to hide global text links if they point to an empty view. (Perhaps this code be used for all field links pointing to an empty view as the empty text option is often not very user friendly, I'd rather not send users to 'blank' pages at all and just hide the links). I am not a coder so apologies for this. I am presuming the first part of the code is to get the argument from the url, then get the field as a url adding the argument, then get the view from the url... check if the view has empty text then return or print Url or not. Is this a slow process to do in the view blocks?
Here's what I am 'trying' to hack together (and I really don't know what I am doing)
//get the argument ...
function check_view_menu( ){
$alias = drupal_get_path_alias( $_GET["q"] );
$alias_array = explode("/", $alias);
$argument = $alias_array[4];
// Get the field as links? How do I do this? Field plus argument...
$links = ?
//get the view
foreach ($links as $link_text => $view_name){
if ($view_name){
$view = views_get_view($view_name);
$view->set_arguments( array( $argument ) );
$view->init_display();
$view->pre_execute();
$view->execute();
if ( count($view->result) > 0 ){
// print link or not
return $link_text;
}
}else{
return null;
}
}
}
Thanks
Comments
Comment #1
dawehnerThats just my oppinion: This kills your site performance, if you really have to check whether the view is empty. So for every block you have to fire up the whole view.
PS: Please provide code snippets/code questions in < code > < / code > Parts. Thanks.
Comment #2
esmerel commentedNo response to request for more info