Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I've used this module on a number of sites and it saves so much time, thank you for writing it!
I was wondering if anyone could explain how to add the title of the menu as a class for my menu block.
On my site the menu block requires special styling for each section, so I could use the menu title as a class to target each section. I am using Zen and it already provides a section class in the body, but some of my paths are not correct to the section body class won't work in this situation.
Thanks!
Comments
Comment #1
mlncn CreditAttribution: mlncn commentedThe dev version of menu_block has a hook_menu_block_tree_alter which you can implement in a custom module to make these modifications and many more. We're using it and it is stable.-
The ugly part is recursing through every menu item but if you know the depth you care about you can skip a lot...
This code is a) untested, b) relies on the latest dev of menu_block, and c) requires the zen theme or stealing the zen_id_safe function out of it for yourself. So it's almost guaranteed not to work for you-- but that's the approach, and i do recommend the dev version-- congrats to JohnAlbin! Maybe we can work out best practices for use of hook_menu_block_tree_alter in this comment thread, or come to think of it maybe there is / should be a much easier alter hook for what you need to do... or maybe a theme hook works for this.
benjamin, agaric
Comment #2
codecouleurs CreditAttribution: codecouleurs commentedTo add class in the element which has id "block-menu-block-yourblockid" I use the yourtheme_preprocess_block(&$vars) function in template.php file.
Menu block module already uses a different title for each block so I choose to use this title to create the classe. Like this the classe is different for each item menu and I can use special styling for each.
Comment #3
JohnAlbin