How to hide View Page Menu if there is no content? I'm using the Views module (7.x-3.14) and I have a news view which shows all the articles on a page. I also have its Menu settings set to Normal, thus adding News to my navigation.

This works as expected; however, if there are no articles published, I would like the News link not to be added to my navigation. Essentially I would like a No results behavior for the menu.

Is there a way to accomplish this?

EDIT: I'm using Zurb_Foundation as my base theme which uses a custom function to create the menu that is called in preprocess_page. What I was attempting to do remove News from the menu at this point.

function theme_links__topbar_main_menu(&amp;$variables) {
  // We need to fetch the links ourselves because we need the entire tree.
  $links = menu_tree_output(menu_tree_all_data(variable_get('menu_main_links_source',     'main-menu')));
  foreach ($links as $link){
    if(is_array($link) &amp;&amp; array_key_exists('#title', $link)) {
      if($link['#title'] == 'News'){
        $view = views_get_view('news');
        echo count($view-&gt;result);
        echo $view-&gt;total_rows;
      } 
    }
  }
  $output = _zurb_foundation_links($links);
  $variables['attributes']['class'][] = 'right';

  return '&lt;ul' . drupal_attributes($variables['attributes']) . '&gt;' . $output . '&lt;/ul&gt;';
}


count($view-&gt;results) returns 0 and $view-&gt;total_rows returns NULL even though there should be results.
There are multiple options do do this, but all seem to require custom coding.

Maybe Hiding tab when view is empty or How to find out programmatically if a view has a result before rendering the whole view? give an idea of how to do that. They are both mainly about Drupal 6, but the same principles apply.

I would probably use some hook_preprocess or theme function, load the view using views_get_view(), execute that with all the necessary arguments if any, then check the result count and if that's empty, remove the menu link from the page. That last part is described in How to hide menu items without relying on permissions [SOLVED] and Customizing menu link output

Update:
So in your example you could do:

$view = views_get_view('news');
$view-&gt;execute();
$link['#access'] = count($view-&gt;result) &gt; 0;