The Media Gallery block currently gets two sets of contextual links attached to it. This is described in the following bug report against Drupal core: #870434: Contextual links can be displayed more than once for the same element.

However, it turns out that trying to fix it in core has other side effects, so we should fix it here instead. That is done in the attached patch.

Basically, by allowing the media gallery node to live in a subelement of the $block['content'] array, rather than at the top level, we allow the node and block to be rendered separately without them being passed through the contextual links system twice. And to get the contextual links to render where we want them to, all we have to do is move the node's #contextual_links property itself up to the top level of $block['content'], and leave the rest alone.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Status: Needs review » Fixed

Committed in preparation for the upcoming beta release of the module.

http://drupalcode.org/project/media_gallery.git/commit/a7d8a1a

Sylvain Lecoy’s picture

That's exactly what i am looking for. Thanks.

Sylvain Lecoy’s picture

I'm having a problem with this patch, the 'more_link' is then part of the block and not part of the gallery like it was.

You should change $block['content']['more_link'] to $block['content']['gallery']['more_link'] in your patch to respect the tree form.

David_Rothstein’s picture

In what way is that causing a problem?

Generally Drupal puts "More" links at the bottom of the block itself (not appended inside some part of the block's content). So this change made it more consistent with other blocks, which seems better to me.

For example, if I enable the core Blog module and and put its "Recent blog posts" block on my site, then with this patch, the "More" links on that block and the "More" links on the gallery blocks are styled consistently. But before this patch, they had different styling.

Sylvain Lecoy’s picture

Oh I see, I wasn't aware of other default bloc, then this is a good thing :)

Thanks for the reply.

Status: Fixed » Closed (fixed)

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

pjcdawkins’s picture

With media_gallery-7.x-1.0-beta7 I get contextual links twice in gallery nodes (not blocks), is this related, or fixed, or should I open a new bug report/support request?

Each photo appears to inherit links from both File API and Media:

Edit: /file/36536/edit?destination=node/67621
Delete: /file/36536/delete?destination=node/67621
Edit: /media-gallery/detail/67621/36536/edit?destination=node/67621
Remove: /media-gallery/detail/67621/36536/remove?destination=node/67621

(screenshot attached)

jazzitup’s picture

Issue summary: View changes

Even with the latest dev, this issue is still present (7.x-1.x-dev 2015-Oct-17).

(*)
Edit
Delete
Edit
Delete

jazzitup’s picture

Status: Closed (fixed) » Active
ivnish’s picture

Status: Active » Closed (outdated)