I want to add more contextual links (e.g. "Edit Block") to my block apart from the existing "Configure Block".

How can I achieve this?

  • The existing answer is 7.x code. I haven't tried it yet, but based on api.drupal.org/api/drupal/…, you simply have to put something like that in $build return by your block plugin. Or alter it in
    – Berdir
    Jan 15 '17 at 23:39

I know that this blog post is 100 years old, but it still applies:


The basic idea is to make use of hook_contextual_links_view_alter

For example:

function MYMODULE_contextual_links_view_alter(&$element, &$items) {
  // This hook is called for EVERY set of contextual links
  // on a page.  We first want to check the $element to make
  // sure we are adding a link to the correct list of contextual
  // links. In this case we only want to add a link to blocks
  // created by the "search" module. We just add links using the
  // same array structure as is used by theme_links.
  if (isset($element['#element']['#block']) && $element['#element']['#block']->delta == "site_tweets-site_tweets_block") {
    $element['#links']['social-networks'] = array(
      'title' => 'Edit social network links',
      'href' => url('/admin/config/system/site-information', array('absolute' => TRUE)),
  • Please try not to post link only answers, as links can go down over time. Better is to include the essential part of the answer here and provide a link for further reference. Could you edit your post? Jan 15 '17 at 21:55
  • Also note that OP is referring to the Quick Edit api specifically, for which there is hardly any documentation at all except for Doxygen. Jan 16 '17 at 1:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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