#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')),
    );
}

Comments

misc’s picture

StatusFileSize
new2.43 KB

Suggested patch attached.

misc’s picture

Status: Active » Needs review

And the right status...

misc’s picture

StatusFileSize
new14.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
StatusFileSize
new2.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
StatusFileSize
new3.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
StatusFileSize
new3.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

StatusFileSize
new3.44 KB

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;
}
japerry’s picture

Status: Needs work » Closed (outdated)

Drupal 7 is no longer supported, closing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.