Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I would like to know how to hide menu block if some active trail have no children. I explain :
My main menu tree is someting like :
- A
- A.1
- A.1.1
- A.1.2
- A.2
- B
- B.1
- B.2
- B.2.1
- B.2.2
I configure menu block to start at level 1 so, when I'm on A1, the menu block is :
- A.1
- A.1.1
- A.1.2
- A2
But when I'm on A2, it is :
- A1
- A2
Because A2 has no clidren, I don't want to display the menu block. How can I do ?
By the way, is there an option to hide siblings too (don't show A2 when I'm on the A1 trail).
Thank you for your help.
Comments
Comment #1
dcanetma CreditAttribution: dcanetma as a volunteer commentedHola,
I think I found a solution for this.
On your module, use this hook:
I hope it helps @jofdesign.
Cheers,
D.
Comment #2
JoshaHubbers CreditAttribution: JoshaHubbers at iO commentedA little late reaction, but for the record... ;-).
The idea is ok, but the main problem is that the module is not implementing this the right way:
See #3199909: _menu_tree_prune_active_tree level is passed wrong parameter.
You can also use: