Missing "Edit Block" Contextual Link

Created on 10 August 2018, almost 6 years ago
Updated 24 February 2023, over 1 year ago

Problem/Motivation

πŸ› contextual links for entity view Fixed changed the way that contextual links are added to BEANs. On some sites, this change led to contextual links no longer displaying on BEAN blocks.

Workaround

One option to restore the previous behaviour without patching is to implement hook_block_view_alter() in a custom module:

/**
 * Implements hook_block_view_alter().
 *
 * Conditionally adds contextual links.
 *
 * @see https://www.drupal.org/project/bean/issues/2991960
 */
function mymodule_block_view_alter(&$data, $block) {
  if (!module_exists('contextual')) {
    return;
  }
  $bean = bean_load_delta($block->delta);
  $bean_is_viewable = entity_access('view', 'bean', $bean) && $bean;
  $block_has_content = !empty($data['content']);
  if ($bean_is_viewable && $block_has_content) {
    $data['content']['#contextual_links']['bean'] = [
      'block', [$bean->Identifier(), 'edit']
    ];
  }
}

Original issue report

After upgrading from 7.x-1.11 to 7.x-1.13, I no longer have the Edit Block contextual link on my Bean-created blocks. I would guess this is related to changes in πŸ› contextual links for entity view Fixed .

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States zengenuity

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada nedjo

    While this is a regression for some sites, it results from changes in πŸ› contextual links for entity view Fixed that benefitted other sites or use cases and at this point is unlikely to be rolled back. Hence marking won't fix.

    One option to restore the previous behaviour without patching is to implement hook_block_view_alter() in a custom module:

    /**
     * Implements hook_block_view_alter().
     *
     * Conditionally adds contextual links.
     *
     * @see https://www.drupal.org/project/bean/issues/2991960
     */
    function mymodule_block_view_alter(&$data, $block) {
      if (!module_exists('contextual')) {
        return;
      }
      $bean = bean_load_delta($block->delta);
      $bean_is_viewable = entity_access('view', 'bean', $bean) && $bean;
      $block_has_content = !empty($data['content']);
      if ($bean_is_viewable && $block_has_content) {
        $data['content']['#contextual_links']['bean'] = [
          'block', [$bean->Identifier(), 'edit']
        ];
      }
    }
    
Production build 0.69.0 2024