When a bean is rendered in a region (using context in my case), the contextual links that allow you to quickly edit the bean are now missing. These were working in the past.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kingandy’s picture

There seems to be a reliance on access to the "Bean Page". On my install at least, a user with just the "Edit Bean" permission(s) did not see the contextual link; adding the "View Bean page" permission prompted the link to appear.

IMO this is a bug, people with permission to edit beans should be able to do so via the contextual link.

kingandy’s picture

... regardless of whether they can see the bean in question via its own path.

kingandy’s picture

Having looked into this a little - the "Contextual Links" element is driven by the menu system, and the Bean is basically giving the link to the view page and expecting it to find the submenu tabs (edit, etc) itself. This is the intended behaviour for Contextual Links; it's not expected that anyone would have access to a tab but not the parent menu item.

I'm not sure if it's appropriate to subvert this behaviour - it would be possible to pass in the full path ('block/[bean-delta]/edit'), or something, but the Contextual module is fairly emphatic about not including dynamic elements (such as the bean-delta) in the first path. I'm assuming this would be for efficiency, not wanting to recalculate the tabs over and over. Maybe it would be preferable to make a new access callback for block/%bean, which would make that path automatically visible to anyone with permission to edit the bean?

Brandonian’s picture

Status: Active » Needs review
FileSize
1017 bytes

If a custom bean does not return a render array for it's content, bean will currently error out because of how it currently sets contextual links. Attached is a patch which implements hook_contextual_links_view_alter for the bean module, which will replace the current block contextual link with a link to the bean block edit page.

function bean_contextual_links_view_alter(&$element, $items) {
  if (isset($element['#element']['#block']->module) && $element['#element']['#block']->module == 'bean') {
    $element['#links']['bean-configure'] = array(
      'title' => t('Edit block'),
      'href' => 'block/' . $element['#element']['#block']->delta . '/edit',
    );
    unset($element['#links']['block-configure']);
  }
}
fmitchell’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Paul Lomax’s picture

Title: contextual links not working » Contextual links not working
Status: Closed (fixed) » Needs review

This seems to have broken contextual links when using Panels to embed Beans. Reverting back the code from bean_block_view seems to fix this. Unless i'm missing something.

chriscohen’s picture

Confirmed. If a bean appears within a panel, the patch above breaks the contextual links. Panels does not respect hook_contextual_links_view_alter() so it never gets called and hence the patch above doesn't have any effect on beans that are within panels.

The original method, using bean_block_view() to insert contextual links, is more robust and works a lot better. A new angle is going to be needed to make this work, unless anybody feels like trying to patch the way panels invokes contextual links.

indytechcook’s picture

Status: Needs review » Fixed

Here you go. http://drupal.org/commitlog/commit/22232/5b5772bcf56fc9299cb041417b8a022...

I checked to make sure a render array was returned by the plugins.

fmitchell’s picture

Really....a not empty in an array? Shoot me in the face now. :-p

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

SebCorbin’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review
FileSize
406 bytes

We have lost the point made in comment #1

There seems to be a reliance on access to the "Bean Page". On my install at least, a user with just the "Edit Bean" permission(s) did not see the contextual link; adding the "View Bean page" permission prompted the link to appear.

We need to add the 'edit' arg to the contextual link

Patch attached

indytechcook’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

eric.chenchao’s picture

Version: 7.x-1.x-dev » 7.x-1.7
Status: Closed (fixed) » Closed (duplicate)

I believe this is duplicate to #1949058: No edit option.

Apply the patch and clear cache should fix this.

eric.chenchao’s picture

Version: 7.x-1.7 » 7.x-1.x-dev

Ignore the above comment. Update in the wrong place. Sorry.

eric.chenchao’s picture

Status: Closed (duplicate) » Closed (fixed)