Using Drupal 7, if you need some logic to programmatically determine whether you show or hide something based on whether a view returns any results or not, you can use the following code.

$view = views_get_view( 'your_view_machine_name' );
$view->set_display( 'your_display_name' );

if ( $view->result ) {
    // Results
else {
    // No results

Leave a Reply

Your email address will not be published. Required fields are marked *

Continue Reading