Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I use the default Drupal core 8.2.4
When I rendered blocks on a page with context, all contextual links on blocks are missing (the cog icon on the top right of the block where you can choose to Configure Block, Quick Edit and Edit).
Does anyone here have the same issue?
Comment | File | Size | Author |
---|---|---|---|
#21 | 2853565-21.patch | 1.78 KB | weynhamz |
#15 | context_missing-contextual-links_2853565_15.patch | 5.05 KB | boshtian |
#11 | context_missing-contextual-links_2853565_11.patch | 1.84 KB | icurk |
#9 | 2853565-block_content_using_context.png | 31.85 KB | Grimreaper |
#9 | 2853565-block_content_using_block_layout.png | 33.03 KB | Grimreaper |
Comments
Comment #2
pascavi CreditAttribution: pascavi commentedSame here
Comment #3
s1work CreditAttribution: s1work commentedI'm having the same issue.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI did some searching and it looks like this is related to https://www.drupal.org/node/2666578
Comment #5
icurk CreditAttribution: icurk commentedThis patch adds contextual links to blocks.
Comment #6
icurk CreditAttribution: icurk commentedThe previous patch was missing the contextual link for configuring block on context.
Comment #7
GrimreaperHello,
I have just tested the last patch on the last dev version of context.
There are warnings that are no more here the blocks in contexts are resaved.
There is now an edit link on content block but no quick edit link and there is no contextual link on blocks provided by plugin.
EDIT: I need to continue testing without the patch. I have a JS error on my pages (not due to context) and so no more contextual links.
Comment #8
icurk CreditAttribution: icurk commentedHi Grimreaper,
I read your comment multiple times, but still not sure what you wanted to say. The only thing I understand is that quick edit link is missing from in contextual links.
Could you please explain what you meant with
and
.
Comment #9
GrimreaperHello,
@icurk: sorry for the delay.
I have redone test using a standard Drupal install and using the Bartik theme to be sure to not have other modules interfering.
About the warnings
Here is a screenshot of the warnings I have once the patch is applied:
It is because for existing context placing blocks, the context is not defined. After resaving the blocks in the contexts it is ok.
I don't know if you want to put a check in the code or an upgrade path for existing contexts or say to update the contexts manually.
About the contextual links (once the contexts have been saved and there is no more warnings):
Contextuals links are ok except for the quick edit contextual link. I attached two screenshots.
The blocks on the left sidebar are placed using "block layout" and the block "mon block custom" is a content block and it has the "quick edit" link that is working.
The blocks on the right sidebar are placed using context and the block "mon block custom context" is the same content block and it does not have the "quick edit" link.
Maybe quick edit integration can be done in another issue.
Comment #10
GrimreaperQuick edit issue: #2876515: QuickEdit integration
Comment #11
icurk CreditAttribution: icurk commentedI wrote an update hook, which will set context_id on all blocks inside block reactions in all contexts.
Comment #12
boshtian CreditAttribution: boshtian commentedI tested patch in #11.
For all the blocks that only have "Configure block" contextual link, we have a contextual links cog in the corner, but there is no links when you click on it.
I agree that we don't need to render the "Configure block" link if we put the block on page through Context, since it would take you to the block edit page of the default block layout and those settings would not affect the block displayed through Context.
But for closing this issue, I think it would be good if we can just remove the cog icon if there is no links.
We can also add a fix which would add a "Configure block" link, but instead taking you to default block layout settings, it would take you to the block settings inside of the Context that is providing this block.
If this is too big of an effort, we can open separate issue for this.
Comment #13
Grimreaper@boshtian there is no contextual link because the patch from #11 is missing parts of the code...
Test the patch from comment #6
Comment #14
boshtian CreditAttribution: boshtian commentedThanks Grimreaper.
I just realized that and came back to this issue, to correct myself, but I see you were faster. :)
OK, then I think we need a patch that will include everything from #6 and update hook from #11.
Comment #15
boshtian CreditAttribution: boshtian commentedI combined the two patches from #6 and #11 into one patch.
If anyone else can test it, then we can add it to release.
Comment #16
GrimreaperPatch from comment #15 ok for me.
No more warnings after the hook_update_n execution.
Thanks all.
Comment #18
boshtian CreditAttribution: boshtian commentedComment #19
tuthanh CreditAttribution: tuthanh commentedThanks boshtian.
The patch #15 works for me. It is great.
Comment #21
weynhamzThe committed patch introduced an unnecessary `$block->build()` call to get the contextual links, and later in `preRenderBlock()` the `$block->build()` is invoked again, for some blocks, especially menu block, the build operation is heavy. Instead, the code should be in later `preRenderBlock()`.