Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-beta1
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
25 Apr 2008 at 05:08 UTC
Updated:
16 May 2008 at 19:01 UTC
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
Comment #1
merlinofchaos commentedTabs 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.
Comment #2
catchMarking this as fixed for now. Please re-open if that doesn't help.
Comment #3
designerbrent commentedMerlinofchaos,
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.
Comment #4
merlinofchaos commentedThe 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.
Comment #5
catchYou 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).
Comment #6
catchCross posted.
Comment #7
designerbrent commentedOk.. 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.
Comment #8
merlinofchaos commentedOk, 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.
Comment #9
designerbrent commentedThanks 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!
Comment #10
merlinofchaos commentedIt 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.
Comment #11
Rob T commentedThanks 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?
Comment #12
merlinofchaos commentedAt 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.
Comment #13
merlinofchaos commentedDocumentation now in the help.
Comment #14
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.