I'm trying to create menu tabs with the frontpage view that comes with views by default. I have tried setting the menu item to Tab and then naming it but nothing seems to show up. Even after I created a second display for that view and changed the menu item for that nothing shows up.

Is that a feature that is not working yet or am I missing something in how i set it up?

Here is the export of the view i'm using:

$view = new view;
$view->name = 'frontpage';
$view->description = 'The basic front page view.';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = '0';
$view->api_version = 2;
$view->disabled = FALSE; // Edit this to true to make a default view disabled initially
$view->display = array();
  $display = new views_display;
  $display->id = 'default';
  $display->display_title = 'Defaults';
  $display->display_plugin = 'default';
  $display->position = '1';
  $display->display_options = array (
  'style_plugin' => 'default',
  'style_options' => 
  array (
  ),
  'row_plugin' => 'node',
  'row_options' => 
  array (
    'teaser' => 1,
    'links' => 1,
  ),
  'relationships' => 
  array (
  ),
  'fields' => 
  array (
  ),
  'sorts' => 
  array (
    'sticky' => 
    array (
      'id' => 'sticky',
      'table' => 'node',
      'field' => 'sticky',
      'order' => 'ASC',
    ),
    'created' => 
    array (
      'id' => 'created',
      'table' => 'node',
      'field' => 'created',
      'order' => 'DESC',
      'relationship' => 'none',
      'granularity' => '',
    ),
  ),
  'arguments' => 
  array (
  ),
  'filters' => 
  array (
    'promote' => 
    array (
      'id' => 'promote',
      'table' => 'node',
      'field' => 'promote',
      'operator' => '=',
      'value' => '1',
      'group' => 0,
      'exposed' => false,
      'expose' => 
      array (
        'operator' => false,
        'label' => '',
      ),
    ),
    'status' => 
    array (
      'id' => 'status',
      'table' => 'node',
      'field' => 'status',
      'operator' => '=',
      'value' => '1',
      'group' => 0,
      'exposed' => false,
      'expose' => 
      array (
        'operator' => false,
        'label' => '',
      ),
    ),
    'type' => 
    array (
      'id' => 'type',
      'table' => 'node',
      'field' => 'type',
      'operator' => 'not in',
      'value' => 
      array (
        'feedapi_node' => 'feedapi_node',
      ),
      'group' => 0,
      'exposed' => false,
      'expose' => 
      array (
        'operator' => false,
        'label' => '',
      ),
      'relationship' => 'none',
      'expose_button' => 
      array (
        'button' => 'Expose',
      ),
    ),
  ),
  'items_per_page' => 10,
  'use_pager' => '1',
  'pager_element' => 0,
  'title' => '',
  'header' => '',
  'header_format' => '1',
  'footer' => '',
  'footer_format' => '1',
  'empty' => '',
  'empty_format' => '1',
  'use_ajax' => '1',
);
$view->display['default'] = $display;
  $display = new views_display;
  $display->id = 'page';
  $display->display_title = 'Page';
  $display->display_plugin = 'page';
  $display->position = '2';
  $display->display_options = array (
  'defaults' => 
  array (
    'access' => true,
    'title' => true,
    'header' => true,
    'header_format' => true,
    'header_empty' => true,
    'footer' => true,
    'footer_format' => true,
    'footer_empty' => true,
    'empty' => true,
    'empty_format' => true,
    'items_per_page' => true,
    'offset' => true,
    'use_pager' => true,
    'pager_element' => true,
    'link_display' => true,
    'php_arg_code' => true,
    'exposed_options' => true,
    'style_plugin' => true,
    'style_options' => true,
    'row_plugin' => true,
    'row_options' => true,
    'relationships' => true,
    'fields' => true,
    'sorts' => true,
    'arguments' => true,
    'filters' => true,
  ),
  'relationships' => 
  array (
  ),
  'fields' => 
  array (
  ),
  'sorts' => 
  array (
  ),
  'arguments' => 
  array (
  ),
  'filters' => 
  array (
  ),
  'path' => 'frontpage',
  'menu' => 
  array (
    'type' => 'default tab',
    'title' => 'All',
    'weight' => '3',
  ),
);
$view->display['page'] = $display;
  $display = new views_display;
  $display->id = 'page_1';
  $display->display_title = 'Page 1';
  $display->display_plugin = 'page';
  $display->position = '3';
  $display->display_options = array (
  'defaults' => 
  array (
    'access' => true,
    'title' => true,
    'header' => true,
    'header_format' => true,
    'header_empty' => true,
    'footer' => true,
    'footer_format' => true,
    'footer_empty' => true,
    'empty' => true,
    'empty_format' => true,
    'use_ajax' => true,
    'items_per_page' => true,
    'offset' => true,
    'use_pager' => true,
    'pager_element' => true,
    'use_more' => true,
    'distinct' => true,
    'link_display' => true,
    'style_plugin' => true,
    'style_options' => true,
    'row_plugin' => true,
    'row_options' => true,
    'relationships' => true,
    'fields' => true,
    'sorts' => true,
    'arguments' => true,
    'filters' => true,
  ),
  'relationships' => 
  array (
  ),
  'fields' => 
  array (
  ),
  'sorts' => 
  array (
  ),
  'arguments' => 
  array (
  ),
  'filters' => 
  array (
  ),
  'path' => 'news',
  'menu' => 
  array (
    'type' => 'tab',
    'title' => 'News',
    'weight' => '0',
  ),
);
$view->display['page_1'] = $display;

Thanks

Comments

merlinofchaos’s picture

Tabs are a little complicated to set up, and it requires proper parenting. Here are the important rules:

1) It takes 2 tabs to tango. If there aren't at least 2 tabs, Drupal won't show you any tab. So you have to have something else to tab with.
2) Tabs have to have a parent; or at least, the 'default' tab does. Something has to be a default tab, so if you don't define on in Views you have to add your tab somewhere that tabs already exist.

catch’s picture

Status: Active » Fixed

Marking this as fixed for now. Please re-open if that doesn't help.

designerbrent’s picture

Merlinofchaos,

So that means I have to define the tab outside of views first and then define it in views? If so, how do I define those?

Thanks for assistance.

merlinofchaos’s picture

Title: Can't Find Menu Tabs » Document menu tabs with advanced help
Category: bug » task
Status: Fixed » Active

The only other program I know of that lets you define tabs is Panels. But, see, if you only have 1 tab, why do you want a tab, anyhow? I think at this point it's hard to tell what you're trying to accomplish.

I'm turning this into a task to create a help item to provide more discussion about this topic within Views.

catch’s picture

Title: Document menu tabs with advanced help » Can't Find Menu Tabs
Category: task » bug
Status: Active » Fixed

You can define tabs in views, but you need to have at least two paths defined - like tracker/all tracker/user for anything to show up - these paths could both be views, or one could be provided from elsewhere, and one could be from a module.

So, set up one display that has path/tab1path and another which has path/tab2path - and then experiment a little with the settings to get them to show up (I've done this in views one but not views 2 yet).

catch’s picture

Title: Can't Find Menu Tabs » Document menu tabs with advanced help
Category: bug » task
Status: Fixed » Active

Cross posted.

designerbrent’s picture

Ok.. I have tried with two different views to create tabs and still have no luck.

Here is what I have tried:

Created View.
Made a basic display.
Added a url (tracker)
Added a menu tab (All)
Saved the display
Added a second display
Added a url (tracker/user)
Added a menu tab (User)
Saved the view

When I preview it, it still doesn't work.

The $tab variable is still just empty.

merlinofchaos’s picture

Ok, here is the procedure I used to test this; I think I didn't hilite enough of the restrictions (which are Drupal's, not Views'):

1) I created a brand new view. I called it tab_a. I gave it a path of 'tab/a' and I set it to be 'default menu item' with a title of "Tab a". I told it the menu parent will be a normal item with the title of 'Tabs'. Note: If the menu item is tab/a then the default menu item points to tab, because the menu system uses path to determine hierarchy.

2) I created a second brand new view. I called this one tab/b. I gave it a path of tab/b and I set it to being a menu tab (not the default) with a title of 'Tab b'.

I clicked on the 'Tabs' link that appeared and I went to tab/a, which contained two tabs, for A and B.

designerbrent’s picture

Thanks for clarifying. I guess what I missed some key things.
1. The path must have the same parent testview/1 and testview/2
2. The default menu item needs to be set as well.

So after getting your example to work with two different views, I went back to my test with one view and different displays. And I did get it to work.

Not sure what can be done about it as much of that comes from the menu system and not from views, but taking your example, when I click on the menu item 'Tabs', it takes me to /tabs but displays /tabs/a. That is all ok however, it doesn't set any of the tabs to active. Only when I click on "Tab A" does it set 'Tab A' as active and navigates to tabs/a.

Would it make more sense when you click on "Tabs" to make it just go to the default tab?

BTW: I really like Views 2. It is so much easier to manage and work with. All the AJAX is great and the previews are wonderful!

merlinofchaos’s picture

It should make the default tab active (and the real URL for the default tab will be basically hidden) -- I can't realy do anything about that, that's just how the menu system works, and we have to do what Drupal wants.

Rob T’s picture

Thanks for the explanation in #8. It helped my a great deal.

For the menu tab title... is there a way to get arguments (like %1) into the Menu tab titles?

merlinofchaos’s picture

At the time the menu is created, the argument is unknown. And this won't create several menu entries, one for each argument, if that's what you're hoping for.

merlinofchaos’s picture

Status: Active » Fixed

Documentation now in the help.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.