Hi

I have made 2 kinds of search page on my site and I want to user to be able to tab between them. I see that the drupal interface has lots of these tabs, so I'm figuring they must be a theme function of something, however can't seem to find it was expecting someting like

theme_tabs($linksarray, $default)

or am I wide of the mark. Thanks for any help.

James

Comments

mdixoncm’s picture

Unfortunately life is not that easy ...

The building of the tabs is handled by the Drupal menu building stuff - the tabs themselves are actually "local tasks".

The theming of them is handled by theme_menu_local_tasks - which does not take any params, but basically fetches the locals tasks to display (I'm not entirely sure that should happen within a theme function??). Anyway, basically all it does is wrap the tabs inside a <ul class="tabs primary"> or <ul class="tabs secondary">

The actual links themselves are built up using theme_menu_local_task, which basically wraps the list items in <li class="active"> if they are active or just in a standard <li> if they are not.

So - the simplest thing to do would be to just create your own little theme function that takes and array of links and wraps them in same markup used for the local tasks.

Like books? Check out booktribes the new (Drupal based) community for book lovers
from Computerminds

zzJames’s picture

not as simple as I'd hoped, but not too complicated in the end. cheers.

James

harro’s picture

I have a question relating to this topic - when you add tabs in the user profile (using the profile.module), they are ordered alphabetically, usually. However... the default tab "user" (I have a translated version, name may differ) does not conform to this!

So my tabs could be: "User" (default) - "Interests" (new tab) - "Work" (new tab).

Same problem with the standard user tabs "view" - "edit" - "contact". I would like to sort (all) these alphabetically.

Any thoughts on how I could get this to happen? I cannot figure out where the first tab is called and then how it justs to the 'new' profile tabs.

Thank you for feedback!

Harro

nedjo’s picture

The easiest way to get tabs is by registering menu items in a module in a hook_menu() implementation. To see how this is done, search the core .module files for the string MENU_DEFAULT_LOCAL_TASK and look at the items of type MENU_DEFAULT_LOCAL_TASK and MENU_LOCAL_TASK. You can do the same in your module.

If you're wanting Javascript-type tabs that are all loaded for the same page (user clicks between them without page reloads), you can use the tabs module included with Javascript Tools, http://drupal.org/project/jstools. See the README for instructions. Best to develop right now for the HEAD version, as the tab generating code recently changed and will soon be merged into the stable release.

harro’s picture

Thanks Nedjo! It's a starting point :) I sense from your reply that you anticipate me making a whole module, but I am not at that stage yet... First I am trying to order the tab names/descriptions in the profile view (strange by the way, that no one has wanted this before).

Probably not a good idea to hack the user.module where the profile page is built up, but maybe I can make a new page for this. Haven't quite figured out what the difference is in the way page-code is processed between a module and an 'new page' that I make through the create content menu (but that is a whole new discussion).

In any case, if I figure out a way, I'll post it here for all to scrutinize and improve :)

Bya!

Harro

kingandy’s picture

Late to the thred, I know, but FWIW in 5.x and onwards the following should work:
theme('item_list', $linkarray, NULL, 'ul', array('class' => 'tabs'));
(Depending on your theme I guess you may need a <div class="clear-block"></div> around that.)

It's a simple matter of applying the 'tabs' class to your UL element. Unfortunately, according to the API reference for theme_item_list(), it looks like the last (HTML attributes) argument wasn't available in 4.7 and earlier.

--Andy
Developing Drupal websites for Livelink New Media

++Andy