Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timodwhit’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.33 KB

I had the same issue. It looks like we can move the code outside of the block view, into the plugin->view() method. Here is a patch that should resolve the issue.

timodwhit’s picture

Sorry, last patch didn't work quite right:

gmclelland’s picture

I tried the patch in #2 and it did add the contextual links, but it only added "Usage" and "Manage Display". It seems to be missing an "Edit" link.

In my case I have a entity reference field that gets the beans and displays them.

Koen.Pasman’s picture

Thanks for this, I am also using beans in entityreference fields and they do not get contextual links without the patch in #2.

@gmclelland: check you're permissions for that bean type, I am getting the link using the patch here.

gmclelland’s picture

@Koen.Pasman - I'm logged in as admin(user=1) and checked all the permissions. When I visit the bean view page at mysite.dev/block/test-cta, if I hover the page title I see the contextual links with only Usage and Manage Display listed.

To also test, I added an ER field to a content type that references beans. Then I viewed the node and it had the same results.

kappaluppa’s picture

I'm stuck on this as well. I've added the patch, checked all the perms, am also user1, but I don't even see the contexual links with only Usage and Manage Display.

  • I have bean block types (single beans)
  • Then I have a bean block type with entity reference to "single beans" that displays "multiple bean groups".
  • Then I am using Field Collections with entity reference to the 'multiple bean groups' that are displayed on a node (this way the users can manipulate the order of the multi-bean groups).

Contextual links do not show up on any instances of the beans in any of the display types.

kappaluppa’s picture

DOH!! I found my problem. I created custom bean tpls BEFORE I added the patch.

I went to my custom tpl and added

<?php print render($title_suffix) ?>

right where it said to in the patch.

My problem was further compounded by the fact that I had copied the bean.tpl.php file to my theme's template folder. So when I tested a default block (no custom template) it still did not work because I was overriding the module's tpl.

whew!!

It was only by searching around in a whole bunch of posts did I discover that the contextual links come from:
<?php print render($title_suffix) ?>

Hope my stumbles help someone else out! thanks for the patch!

Pol’s picture

Status: Needs review » Reviewed & tested by the community

We had a long discussion internally about this patch.
Should we include the variable $title_suffix without adding $title_prefix and the rest.

Some people disagree on adding it to the template because it doesn't make sense adding without adding the title too.

IMHO I'm in flavor of providing ease to newcomers and provide contextual links by default. If they don't like it, they can override bean.tpl.php and delete the line in it.

dxvargas’s picture

Status: Reviewed & tested by the community » Needs work

@Pol I also don't think to just add the $title_suffix is good.
Like blocks and most of other entities, we should have the all information for the title:

  <?php print render($title_prefix); ?>
  <?php if (isset($bean->title)): ?>
    <h2<?php print $title_attributes; ?>><?php print $bean->title ?></h2>
  <?php endif;?>
  <?php print render($title_suffix); ?>

Be aware that titles will be displayed by default with this patch.
If this is not desired behavior, I suggest people to override the template and/or install the module title.

Please let me know if you agree, then I can submit an improved patch.

Pol’s picture

I agree with the patch now.

This is the default Drupal's behavior, implemented properly.

Even if it will add titles on beans, users will have to find a way to manage this properly.

dxvargas’s picture

Here it is the improved patch, as proposed in #9.

dxvargas’s picture

Status: Needs work » Needs review
netlooker’s picture

Status: Needs review » Reviewed & tested by the community

I've tested the patch and it works like expected. I also agree with @Pol and @dxvargas that the provided solution is the closest to the default Drupal behaviour. This patch also works for views which are rendering beans entities.

DamienMcKenna’s picture

Issue tags: +Needs change record

I think this could use a change record because of the tpl change.

kingandy’s picture

Patch works for me too, (manually applied) against 7.x-1.11

Delphine Lepers’s picture

Status: Reviewed & tested by the community » Needs work
Delphine Lepers’s picture

Assigned: Unassigned » Delphine Lepers
Delphine Lepers’s picture

DamienMcKenna’s picture

Status: Needs work » Needs review
Samvel’s picture

#18 works for me. RTBC from me! Only append new patch with removed trailing whitespaces:
bean-contextual_links_for_entity_view-2084823-18.patch:47: trailing whitespace.

zweishar’s picture

I can confirm that #20 works quite well when inserting a bean into the header / footer of a view.

Bean version: 7.x-1.11
Drupal core version: 7.59

Thanks all for the work here, very much appreciate the effort.

sacarney’s picture

I tested #20 by placing Beans in a View, and it worked great. Looking forward to having this merged in - this would really help our projects.

Pol’s picture

Status: Needs review » Reviewed & tested by the community

Please can we merge this now ?

indytechcook’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

BrightBold’s picture

Note that this patch has caused problems on sites that were rendering the header another way (Panels, etc.) and didn't expect Bean to suddenly start rendering a duplicate header. #2996282: Bean update 7.x-1.13 Causes Duplicate Headers

nedjo’s picture

This also led to the absence of contextual links on some sites, see #2991960: Missing "Edit Block" Contextual Link.