Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
At the moment I there is only one contextual link at a panels page: "Edit Panel".
How can I add additional custom contextual links?
Comment | File | Size | Author |
---|---|---|---|
#4 | contextual-hack.png | 80.01 KB | quicksketch |
Comments
Comment #1
rogical CreditAttribution: rogical commentedtry module 'Custom Contextual Links'
Comment #2
Chipie CreditAttribution: Chipie commentedI using 'Custom Contextual Links'. I can attach these links to views and node but not to the panel contextual links.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedHm. At the moment there isn't currently a way to inject contextual links into a panel. Probably the best way to do this would be to add something via hook_ctools_render_alter() that can be added to the $info file and that could then be added to the links in the build process which happens just after this alter in ctools_context_handler_render_handler(). The patch to do this is probably not terribly difficult to write.
It probably looks something like this:
And a little extra code to ensure that $links is actually an array in case there aren't actually provided by the task handler (which in practice is rare).
Comment #4
quicksketchThis is totally a hack, but after several failed approaches at altering the contextual links on the page, I ended up finding that hook_page_alter() (yuk!) solves this problem. In my situation, I wanted to move the content of the tabs (local tasks) to the contextual links, as shown.
Even though I accomplished this with the following code, it'd still be nice to have a more direct way of handling this.
My module was called "vincia_custom":
After that, just remove the $tabs from being printed in page.tpl.php, and you've got a replacement for tabs on the front-end.
Comment #5
gmclelland CreditAttribution: gmclelland commentedYou might want to check how this is done in Open Atrium they made https://drupal.org/project/contextual_tabs.
There is also the following patches that provide this ability when using the Panels Page Manager:
#1400884-14: Custom menu items in pane dropdown links
#2108413: Add edit link for custom content panes
#1948278: Get an edit link for the view panes in Page Manger
Hope that helps