Contextual links instead of tabs in Drupal 7

Tags

Drupal 7 utilizes contextual links many places. But it still uses tabs on nodes. I wanted my theme to change those tabs to contextual links, so the layout was not altered for the administrative user. I had no clue how to do that, so I asked in the forum, and some helpful people answered. It turned out I needed to find the correct hooks.

 hook_menu_local_tasks() and hook_menu_local_task() 

So I added this code to template.php in my theme to make the tabs contextual instead:

I used the code for this theme, that I am using for vih.dk. I am still struggling a bit with the css for the contextual links (especially in IE, but who is not).

Please feel free to use the comments for suggestions.

Kommentarer

Hi,

I think you can also just use hook_menu_alter() and change the context values of the tabs to not show up as tabs but only as contextual links :) Much less code, let the system take care of the presentation for you. Maybe I'm misunderstanding your goals here?

Gábor

How exactly would you do that?

Hmm...am I missing something or you haven't added "build" for contextual links in your code above? Looks like your code is incomplete!

I do not quite understand what you think is missing? The code above works and is in use on this theme.

Tilføj kommentar