Last updated March 26, 2011. Created by zirvap on October 3, 2006.
Edited by linclark, Roland Tanglao@..., add1sun, merlinofchaos. Log in to edit this page.
Users visiting your site will explore your categories (taxonomies). They will want to see what's new in your taxonomies, so the default "newest" listing is fine... but what if they want to find something particular and want your taxonomy items sorted alphabetically ?
With views, your visitors can easily switch from an "alphabetical" view, to a "newest" view. Here is how to create two tabs (Alphabetical / Newest) so users can switch from one view to another:
Default view:
- Override the taxonomy/term view
- Change the URL to taxonomy/term/$arg/newest
- Set the sort criteria to: "Node: Created Time", "Descending" if it is not already the case
- In the page "Menu" settings:
- Check the checkbox "Menu: Provide Menu"
- In "Menu: Menu Title", write a title which will appear on the tab
- Check the checkbox "Menu: Default Menu Tab: Make Default Menu Tab"
- In the dropdown menu "Menu: Default Menu Tab: Parent Menu Item Type", choose "Normal Menu Item"
- Save
Alternative view:
- Clone the taxonomy/term view you just created and edit it as follows:
- Change "Basic Information: Name" to taxonomy_alpha
- Change "Site: URL" to taxonomy/term/$arg/alpha
- Change "Sort Criteria: Field " to "Node: Title", "Ascending"
- In the page "Menu" settings:
- Check: "Menu: Provide Menu"
- Check: "Menu: Provide Menu as Tab"
- In "Menu: Menu Title", write a title which will appear on the tab
- In the dropdown menu "Menu: Default Menu Tab: Parent Menu Item Type", choose "Tab"
- Change "Menu: Tab Weight" to something else for tab ordering (if you leave this out, the tabs will be sorted alphabetically)
- Save
Done.
In this case default view tab selected will be "Newest".
Your tabs will appear only when you set two of them: don't expect to see a tab when only one tab is created.
Of course, you can add as many different tab views as you wish.
Thanks to merlinofchaos for the tip:
http://drupal.org/node/84323
Important Note
The following note is left from the 4.7.x version of this tutorial, it may not be relevant for 5.x
If this isn't working or you, the problem may be the drupal cache, that has to be updated before drupal knows about the new paths. Here is a workaround:
1. After creating and enabling the new view, go to the modules page.
2. Go to update.php and run the update script, even if there are "no updates available".
After that I could access my just created tabs in /$arg/paths (don't forget to substitute $arg!)
References: http://drupal.org/node/104941, Drupal 5 screencast of this tutorial: http://support.bryght.com/node/613
Comments
I assume in D6 one can use a
I am trying to do this for a taxonomy term view in D6 and I notice a few issues:
1.
I assume in D6 one can use a View Display instead of adding a completely new view.
2.
Also I notice my tabs do not appear in preview mode, maybe I have missed sg
3.
It seems for these tabs I need to set a path, like taxonomy/term/%/latest, while I have my taxonomy terms pathautoed like this: tags/%.
If I add this tab will that be pathautoed as well?
Even if not, I assume I should add some kind of directive in robots.txt to block out possible duplicate content, since only the sorting is changed.
Any ideas are welcome.
Cheers,
G
Some of my Drupal sites:
Thank you so much for this
Thank you so much for this tutorial! I've been trying to figure out how to make view tabs for a long time. It worked like a charm. I created the tabs in Views 2, but the steps are very similar.
In Drupal 6
In drupal 6, You might not get the tabs if your menu tree does not have any parent.
ie, if here is our requirement.
We need two tabs
1) search/all (default and /search should also point to this)
2) search/artist
Here is what you do
In main view
PATH: search/all
MENU: Default menu tab
Menu Settings
Parent menu item: Normal menu item -> anything
In alternate view
Path: search/artist
MENU: Menu Tab
Cheers
Bibek Shrestha
http://www.bibekshrestha.com.np
I dont get the tabs
How do I create tabbed pages
Do i need to Create a separate views Or Create 1 View and add Two "Pages" for example I want to create by Year 2009 and 2010. I filter it by Year.
Can you please guide me with this thanks.
Indeed
You would make two pages (displays), set the menu to default tab and the other to menu tab, set the path to document/.. and document/..2. Save and goto the path set as menu. The tabs should now appear.
Joel Box - TotalOnline
Important note -- Page may need a title.
Some themes do not draw the tabs component in the page template unless the page being rendered has a title set. If creating a new View Page display, there may be no page title by default .. make sure to check that title.
Regards,
Jason Fisher
Thank You!!
You just saved me hours of work. Arrgh!
--
www.ambereyes.net
Change Create content/jobs to 2 tabs views:job_list and add jobs
In D6, I want to change Create content/jobs page to 2 tabs page views with job_list and add_jobs.
But i can't do it.
Please tell me the way to excute this as soon as show once.
taeboss
thanks for tutorial but...
Hi all.
Thanks for tutorial; it´s very useful. I was based in this line, but I have a problem.
I have my navigation menu (navigation menu) with links to taxonomy term page.
This pages I themed with views; I add a tabs in order to sort the results.
The question is imposible mantain 'active' the item in menu! Only in the default tab is active.
I think it´s not so strange, to need active the current menu item when you navigate between tabs (it´s the same page!!). True, is not the same uri, but the path is ever the same!
www.sample.com/taxonomy/term/%
www.sample.com/taxonomy/term/%/newest
www.sample.com/taxonomy/term/%/by-author
www.sample.com/taxonomy/term/%/on-sale
Any ideas? I´m looking to solve this problem in order to open my website.
Thanks in advance.