Closed (fixed)
Project:
Context
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Apr 2017 at 06:51 UTC
Updated:
25 Aug 2017 at 07:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
icurk commentedComment #3
boshtian commentedI confirm that the patch is working.
Comment #5
boshtian commentedComment #6
grimreaperHello,
I was testing that and there is still a problem.
Even if the checkbox is checked, if you place a block in a region with context, it will remove the blocks placed in this region in particular with the native "block layout".
Steps to reproduce:
- On a standard Drupal installation
- Enable context, context ui
- Create a context
- Add a block reaction
- Check "Include blocks from Block layout"
- Place a block inside the "sidebar first" region of Bartik
- Save
- The default search block from the left sidebar does not appear
- Change the block you placed with context to the "sidebar second"
- Save
- The default search block from the left sidebar appears
Comment #7
grimreaperHere is a patch that should fix the issue.
Off topic: I don't understand why there is a "return $build" in this foreach.
Comment #8
grimreaperAlso with or without patch from comment #7, if I have the blocks from the default block layout included, I have messages displayed twice.
One in the standard zone and one on the "content" region that is forced by context in its code from src/Plugin/DisplayVariant/ContextBlockPageVariant.php.
Comment #9
icurk commentedThanks @Grimreaper, nice finding. I tested with your patch and I don't get a message displayed twice. You are talking about drupal messages, right? Do you have steps I can take to reproduce this error? Messages are only displayed twice if I put system message block in block layout and also into context.
For the question about "return $build". I put it there because we don't need to loop over all contexts if we already found a context which has "include blocks from def..." checked. I agree that it would be cleaner if we replace "return $build" with "break".
Comment #10
grimreaperThanks @icurk for the explanation.
For the message block, I opened a dedicated issue #2876747: Messages block displayed twice so it does not block the merge of the patch from comment #7.
Comment #11
grimreaperWhen making the patch for #2876747: Messages block displayed twice, I figured out that the block page title was not displayed even though I checked "Include blocks from Block layout"
And I don't understand why the following code is necessary for the main page content:
Yes If I remove this line the main page content block does not appear but it should appear as "Include blocks from Block layout" is checked...
Comment #12
icurk commentedI reviewed patch from #7 and it works. Since Issue with duplicated message has its own issue I think #7 patch can be committed.
Comment #14
boshtian commentedComment #16
tnfno commentedI am on 8.x-1.x-dev and when I select to Include blocks from Block layout I get the a 500 and the following PHP error:
PHP Fatal error: Unsupported operand types in /drupal/core/lib/Drupal/Core/Render/RenderCache.php on line 284Comment #17
d.sibaud commented8.x-1.x-dev, strange behaviour
I have a context with path condition:
/oncologia
/oncologia/*
/oncology
/oncology/*
and reactions:
- body class
- block: one block placed and "Include blocks from Block layout" checked
on /oncologia and /oncology all works, but on /oncologia/* and /oncology/* paths all the blocks are shown except the title block.
1) if I deactivate the context, the block title reappears
2) if I leave the context and plus I add the block title inside the block reaction, it shows correctly, but not honoring its weight:
3) if I change a block weight in the context block's reaction tab (showing the tabledrag-hide td) by ex to -10 and, in the /admin/structure/block another block has an higher weight (es: 0), the block set in context will be shown after the ones configured in the same region in /admin/structure/block
(I'll open another issue for this last one)
Comment #18
luke.leberPatch #7 has an issue. The array_merge_recursive call has the potential to create an invalid data type for the 'max-age' cache key.
This will result in the fatal error that tnfno mentioned.
Admittedly, I don't have the context of this module down (no pun) enough that I can confidently contribute a fix for it, but as food for the other developers' thoughts, would array_replace_recursive work instead? Or perhaps coercing the 'max-age' => array back into an int?
Comment #19
johnhuang0808 commentedHi @Luke.Leber
Thank you for finding the bug.
I tried to fix the invalid
max-agevalue issue in #2902184.Would you take a look and help me test if the patch works for you? Thanks.
Comment #20
icurk commented#17 I created a new issue for the problem with sorting the blocks. Why page title is not shown is still a mystery for me, but a workaround is to place it in context.
Comment #21
maaty388 commentedI fixed title not displaying if using context Here
#17 check it out