#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.

Custom menu item

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')),
    );
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MiSc’s picture

Suggested patch attached.

MiSc’s picture

Status: Active » Needs review

And the right status...

MiSc’s picture

FileSize
14.35 KB

Suggested usage in image.

MiSc’s picture

Issue summary: View changes

language

MiSc’s picture

Issue summary: View changes

Examples are nice.

Michelle’s picture

Issue summary: View changes
FileSize
2.41 KB

This 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.

mrjmd’s picture

Status: Needs review » Needs work
FileSize
3.08 KB

This 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.

mrjmd’s picture

Issue summary: View changes
mrjmd’s picture

Issue summary: View changes
FileSize
3.17 KB

Here'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.

mrjmd’s picture

Here'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:

html.js div.ctools-dropdown div.ctools-dropdown-container ul li a.ctools-custom-dropdown {
  width: auto;
}