Tutorial #3: Create two tabs to sort taxonomy view alphabetically and by created time
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

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
My Drupal sites:
Review Critical
ClipGlobe - World Travel
I created these 100% from concept, to design and build on Drupal.
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