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