In D7, the system module is in charge of the following menu blocks: Navigation, Management, User menu, Main menu, Secondary menu
This means that in order to apply the same styling to all menu blocks, you need to use the following CSS selector:
.block-menu,
#block-system-navigation,
#block-system-management,
#block-system-user-menu,
#block-system-main-menu,
#block-system-secondary-menu {
// styling
}
This is just awful, awful experience for themers and non-obvious. Fortunately, its easy to add the "block-menu" class back to those 5 special case system-provided menu blocks.
function FOO_preprocess_block(&$variables) {
// System menu blocks should get the same class as menu module blocks.
if ($variables['block']->module == 'system' && in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) {
$variables['classes_array'][] = 'block-menu';
}
}
[above code edited after comment #4 was made.]
We should definitely do that to make things easier for themers and to make our stylesheets lighter weight (re: performance).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | system-menu-block-class-845928-4.patch | 2.37 KB | johnalbin |
| #3 | system-menu-block-class-845928-3.patch | 2.32 KB | johnalbin |
| #2 | system-menu-block-class-845928-2.patch | 644 bytes | johnalbin |
| #1 | bartik-block-menu.patch | 2.73 KB | johnalbin |
Comments
Comment #1
johnalbinI've made this change to Bartik's template.php and simplified its style.css.
Comment #2
johnalbinOf course, this really should be fixed in core.
Comment #3
johnalbinNow that Bartik is in core, here's an updated patch to remove the duplicate code that is already in Bartik.
Comment #4
johnalbinOoops. Forgot we should be checking for
$variables['block']->module == 'system'too.Comment #5
moshe weitzman commentedNo brainer
Comment #6
webchickMakes sense. Technically this is a markup change, but it seems to basically just be adding additional classes, and removing specialized code from Bartik to help ease the maintenance burden there. Let's not get too crazy with this trend, though. We need to get D7 out the door.
Committed to HEAD.