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.
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?
Kommentarer
Hi,
By Gábor Hojtsy on 27 jun 2011 at about 13:42.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
Example?
By lsolesen on 27 jun 2011 at about 14:57.How exactly would you do that?
Hmm...am I missing something
By Vik on 13 jul 2011 at about 01:01.Hmm...am I missing something or you haven't added "build" for contextual links in your code above? Looks like your code is incomplete!
Code works
By lsolesen on 30 jul 2011 at about 17:29.I do not quite understand what you think is missing? The code above works and is in use on this theme.
Tilføj kommentar