Ctools custom content type called Custom Panes shows contextual links when you have access permission and you hover over the pane (much like a block shows the contextual links) which allows you to easily configure the content of the pane. After creating my own plugin that is similar to Custom Panes content type (with a few custom fields), I noticed that I do not have contextual links when I hover over my custom panes. I'm wondering if I can set that in the $plugin definition to show contextual links or what the work around would be. I found the template function the panels uses to template_preprocess_panels_pane(&$vars) which actually looks for $vars['content']->content['#contextual_links']. I'm wondering if there is a way to add contextual links to custom ctools content type plugins?

Any advice would be great!

2 Answers 2


You don't need to do that, what you can do is you can implement a hook_menu_alter and do this.

function YOUR-MODULE_menu_alter(&$items) {
  $items['YOUR-PLUGIN-PATH/%ctools_export_ui/edit']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;

and then add your contextual link to your object. If it a block you can add below code in to your hook_block_view.

$block['content']['#contextual_links'] = array(
  'YOUR-CUSTOM-PLUGIN' => array('YOUR-PLUGIN-PATH', array($delta, 'edit'))

Inside the render callback of your custom CTools Content Type include file you can provide admin_links.

Here is an example pane that has a companion edit page at URL admin/config/custom/my_custom_pane_settings


$plugin = array(
  'title' => t('Custom Pane'),
  'single' => TRUE,
  'render callback' => 'my_custom_pane_render',
  'defaults' => array(),
  'category' => t('Page elements'),
  'edit form' => 'my_custom_pane_edit_form',

function my_custom_pane_edit_form($form, &$form_state) {
  return $form;

function my_custom_pane_render($subtype, $conf, $args, $context) {

  // Output.
  $block = new stdClass();

  // Define pane title & content.
  $block->title = 'Default pane title';
  $block->content = 'My custom pane content';

  // Add custom contextual links.
  $block->admin_links = array(
    'my_custom_pane' => array(
      'title' => t('Edit my custom pane'),
      'href' => 'admin/config/custom/my_custom_pane_settings',
      'query' => array(
        'destination' => current_path(),

  return $block;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.