0

local tasks

I'm using Drupal 9.2.6 with Group module and I want to remove some tabs from local tasks block and rename some of them.

I've created the module and placed above code with hook_menu_local_actions_alter and hook_menu_local_tasks_alter:

function mymodulename_menu_local_actions_alter(&$local_actions) {
   $local_actions['view.group_members.page_1']['title'] = t('Users');
}


function pacifica_menu_local_tasks_alter(&$data, $route_name) {
   unset($data['tabs'][0]['entity.group_content.collection']);
}

The route names where received from webprofiler.

Seems that code doesn't work - Members tab is not renamed to Users, and All entities tab is not hidden. And yes, I've cleared the caches.

Could someone, please, point me to the right direction in solving this?

6
  • Does this answer your question? How to alter local tasks menu titles?
    – leymannx
    Jan 26, 2022 at 20:18
  • Seems that my problem is that I can't find right variables for particular local task. How can I print all variables used in local tasks block?
    – Alex Sh
    Jan 27, 2022 at 8:48
  • composer install drupal/devel_kint_extras && drush -y en devel_kint_extras, then go into your hook and put ksm($variables); , then drush cr and visit the site and it will print you a nicely formatted var_dump into the messages block which by default is placed on some region on the top of the site.
    – leymannx
    Jan 27, 2022 at 8:56
  • oh, man, thank you so much! I've used kint($data); and received the tabs array with all variables! then unset($data['tabs'][0]['group.content']); worked for me!
    – Alex Sh
    Jan 27, 2022 at 12:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.