Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
#1400884: Custom menu items in pane dropdown links adds an alter hook for the menu on the panel panes, it should be nice to also have one on the display menu. Patch will follow.
Example:
/**
* Implements hook_panels_get_display_links_alter().
*/
function mymodule_panels_get_display_links_alter(&$link, $display) {
$links['bottom'][] = array(
'title' => t('My custom item'),
'href' => url('admin/conf/mymodule', array('absolute' => TRUE)),
'attributes' => array('target' => array('_blank')),
);
}
Comment | File | Size | Author |
---|---|---|---|
#8 | alter_display_menu-1948214-8.patch | 3.44 KB | mrjmd |
#7 | alter_display_menu-1948214-7.patch | 3.17 KB | mrjmd |
#5 | alter_display_menu-1948214-5.patch | 3.08 KB | mrjmd |
#4 | alter_display_menu-1948214-4.patch | 2.41 KB | Michelle |
#3 | custom_panels_menu_item.png | 14.35 KB | MiSc |
Comments
Comment #1
MiSc CreditAttribution: MiSc commentedSuggested patch attached.
Comment #2
MiSc CreditAttribution: MiSc commentedAnd the right status...
Comment #3
MiSc CreditAttribution: MiSc commentedSuggested usage in image.
Comment #3.0
MiSc CreditAttribution: MiSc commentedlanguage
Comment #3.1
MiSc CreditAttribution: MiSc commentedExamples are nice.
Comment #4
MichelleThis works as advertised but the patch adds some unneeded whitespace. My patch is just removing that. I took a guess at the comment number because the comment numbering on this issue is really strange. So apologies if it doesn't match up.
Comment #5
mrjmd CreditAttribution: mrjmd commentedThis works as far as adding new links, but I think there's still a few issues. I've made a few changes:
1) Updated the alter name to be prefixed with panels.
2) Removed $pane and $content_type parameters from alter that were empty anyway.
3) Made a categories variable to put into the foreach.
4) Added the example to the panels api file.
5) One more whitespace fix.
Needs work still, because:
1) Css weirdness, shown in the original screenshot.
2) We need more context passed into the hook or we can only add links everywhere, instead of targeting a variant.
Comment #6
mrjmd CreditAttribution: mrjmd commentedComment #7
mrjmd CreditAttribution: mrjmd commentedHere's a slight improvement on the problem 2) above. In this patch we at least pass in the $display object. The only way I see of getting at the handler and task/variant here is by parsing the $display->cache_key though, which seems less than optimal.
Leaving at needs work.
Comment #8
mrjmd CreditAttribution: mrjmd commentedHere's another attempt with the CSS fix, but now it spans into CTools module as well. I'll submit a patch over to that issue queue and relate it back to this one.
The CTools patch is just a single addition to the dropdown.css file: