Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In a node, I use an entity reference to select beans. When displaying the node, the beans are rendered not as blocks. And then they don't have any contextual links.
Comment | File | Size | Author |
---|---|---|---|
#20 | bean-contextual_links_for_entity_view-2084823-20.patch | 1.53 KB | Samvel |
| |||
#11 | 2084823.patch | 1.57 KB | dxvargas |
#2 | bean-contextual_links_for_entity_view-2084823-2.patch | 1.36 KB | timodwhit |
Comments
Comment #1
timodwhit CreditAttribution: timodwhit commentedI 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.
Comment #2
timodwhit CreditAttribution: timodwhit commentedSorry, last patch didn't work quite right:
Comment #3
gmclelland CreditAttribution: gmclelland commentedI 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.
Comment #4
Koen.Pasman CreditAttribution: Koen.Pasman at Aubergine IT commentedThanks 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.
Comment #5
gmclelland CreditAttribution: gmclelland commented@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.
Comment #6
kappaluppa CreditAttribution: kappaluppa as a volunteer commentedI'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.
Contextual links do not show up on any instances of the beans in any of the display types.
Comment #7
kappaluppa CreditAttribution: kappaluppa as a volunteer commentedDOH!! 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!
Comment #8
PolWe 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.Comment #9
dxvargas CreditAttribution: dxvargas commented@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:
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.
Comment #10
PolI 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.
Comment #11
dxvargas CreditAttribution: dxvargas commentedHere it is the improved patch, as proposed in #9.
Comment #12
dxvargas CreditAttribution: dxvargas commentedComment #13
netlooker CreditAttribution: netlooker at European Commission and European Union Institutions, Agencies and Bodies commentedI'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.
Comment #14
DamienMcKennaI think this could use a change record because of the tpl change.
Comment #15
kingandy CreditAttribution: kingandy commentedPatch works for me too, (manually applied) against 7.x-1.11
Comment #16
Delphine Lepers CreditAttribution: Delphine Lepers at Trasys for European Commission and European Union Institutions, Agencies and Bodies commentedComment #17
Delphine Lepers CreditAttribution: Delphine Lepers at Trasys for European Commission and European Union Institutions, Agencies and Bodies commentedComment #18
Delphine Lepers CreditAttribution: Delphine Lepers at Trasys for European Commission and European Union Institutions, Agencies and Bodies commentedReplacing isset with !empty
Comment #19
DamienMcKennaComment #20
Samvel CreditAttribution: Samvel at DrupalJedi commented#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.
Comment #21
zweishar CreditAttribution: zweishar at Isovera commentedI 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.
Comment #22
sacarney CreditAttribution: sacarney as a volunteer commentedI 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.
Comment #23
PolPlease can we merge this now ?
Comment #25
indytechcook CreditAttribution: indytechcook as a volunteer commentedYES WE CAN!
https://www.drupal.org/commitlog/commit/22232/67ef69c04242031c64f1e371b6...
Comment #27
BrightBoldNote 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
Comment #28
nedjoThis also led to the absence of contextual links on some sites, see #2991960: Missing "Edit Block" Contextual Link.