currently the links of the "group operations block" of group module are displayed in a dropbutton menu. I want them to get displayed in a "normal" link list. I found an issue (https://www.drupal.org/project/group/issues/3015420) related to this on d.o.
I have already a custom module to handle my group stuff, so I thought to implement a block_build_alter hook to modify the link type like in the patch (https://www.drupal.org/files/issues/2019-09-27/replace_dropbutton_by_simple_links-3015420-5.patch) mentioned.
Problem is, that the block_build_group_operations_alter function doesn't fire in any way.
Here's my code:
...
use \Drupal\Core\Block\BlockPluginInterface;
...
function MY_MODULE_block_build_group_operations_alter(array &$build, BlockPluginInterface $block)
{
$links = $build['#links'];
unset($build['#type']);
unset($build['#links']);
foreach ($links as $l) {
$t = $l['title']->render();
$build[$t] = [
'#title' => $t,
'#type' => 'link',
'#url' => $l['url'],
'#attributes' => [
'class' => ['group-operations-link']
]
];
}
}
I think it's important to mention that I use twig Tweak module to render the group operations block in twig, because I wasn't able to do this in another way:
{{ drupal_block('group_operations', {context_mapping: {group: '@group.group_route_context:group'}}) }}
I estimate everything has to do with the context mapping but I didn't figure it out how it works. I found this (How can I programmatically display a block?) but there's nothing explained about context stuff. I only know that the group operation block needs the related group entity id as param.