- π¦πΊAustralia imclean Tasmania
This would be very useful. Can you provide a patch or MR?
When the Page Title and/or Main Content Block is in a block group they are always displayed. They ignore any visibility settings from the respective block configuration. They still respect the visibility settings of the block group itself. Any other block or block type placed in a block group can have its own visibility settings as excepted. Only Page Title and Main Content blocks are affected.
See above. Add a page title block or main content block to any block group and change the visibility setting for either block (page title or main content) and see that the visibility for the respective block does not change. The block always displays.
In file: src/Plugin/Block/BlockGroup.php , in function build() :
For the Main content block:
Replace
// Special condition for Main block.
if ($block->getPluginId() == 'system_main_block') {
$renderedBlocks[$block->id()] = $this->mainContent;
}
with this:
// Special condition for Main block.
if ($block->getPluginId() == 'system_main_block') {
/** @var \Drupal\Core\Access\AccessResultInterface $accessResult */
$accessResult = $block->access('view', NULL, TRUE);
if ($accessResult->isAllowed()) {
$renderedBlocks[$block->id()] = $this->mainContent;
}
}
And for the Page Title:
replace:
// Special condition for Title block.
elseif ($block->getPluginId() == 'page_title_block') {
$title = $this->titleResolver->getTitle($this->request, $this->routeMatch->getRouteObject());
$renderedBlocks[$block->id()] = [
'#type' => 'page_title',
'#title' => $title,
'#weight' => $block->getWeight(),
];
}
with this:
// Special condition for Title block.
elseif ($block->getPluginId() == 'page_title_block') {
/** @var \Drupal\Core\Access\AccessResultInterface $accessResult */
$accessResult = $block->access('view', NULL, TRUE);
if ($accessResult->isAllowed()) {
$title = $this->titleResolver->getTitle($this->request, $this->routeMatch->getRouteObject());
$renderedBlocks[$block->id()] = [
'#type' => 'page_title',
'#title' => $title,
'#weight' => $block->getWeight(),
];
}
}
Note:
This takes the if ($accessResult->isAllowed()) {
check from the 'Any other block' else statement below and applies it to both Page Title and Main Content 'Special Condition' statements.
More testing or review is probably needed.
Active
1.5
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
This would be very useful. Can you provide a patch or MR?