0

I have a view displaying a list a menu of all the content for a node. It contains a list of all the fields and views on the page, with the output rewritten as a link eg link to field A . I can do this fine for each field but I also have a view 'teachers' exposed as a block. If the view has content I want to have a link to it in the menu. I'm trying to use Views PHP to code if the view has content, echo '' What function do I call to see if the view exists and has content? I've tried if(views_get_view('teachers) == TRUE){ echo "";} but this always returns TRUE even if there is no content for that view for a specific node.

I want to do something similar to

2 Answers 2

2

You can look at views_get_view_result() and do something like this:

$result=views_get_view_result('teachers');
if (isset($result[0])) {
  // we have results
} else {
  // we don't
}
0

It can be done simpler without querying for a result

$view = views_get_view('my_view_name');
if($view) {
  //continue logic..
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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