Skip to content

Instantly share code, notes, and snippets.

@msankhala
Forked from gagarine/template.tpl.php
Created July 29, 2014 16:24
Show Gist options
  • Save msankhala/f06ef3382434bc404f64 to your computer and use it in GitHub Desktop.
Save msankhala/f06ef3382434bc404f64 to your computer and use it in GitHub Desktop.
<?php
/**
* Theme_menu_tree doesn't provide any context information
* THIS SUCKS
* But you can use hook_block_view_alter to change the theme wrapper
* OUF!
*/
function MYTHEME_menu_tree(&$variables) {
return '<ul class="nav">' . $variables['tree'] . '</ul>';
}
function MYTHEME_menu_tree__menu_top_menu(&$variables) {
return '<ul class="nav center">' . $variables['tree'] . '</ul>';
}
//main menu (top) using the menu block module
function MYTHEME_menu_tree__menu_block__2(&$variables) {
return '<ul class="nav main-nav nav-horizontal">' . $variables['tree'] . '</ul>';
}
//main menu (level 2 sidebar) using the menu block module
function MYTHEME_menu_tree__menu_block__1(&$variables) {
return '<ul>' . $variables['tree'] . '</ul>';
}
function MYTHEME_menu_tree__menu_block__1__level1(&$variables) {
return '<ul class="nav nav-list">' . $variables['tree'] . '</ul>';
}
/**
* Implements hook_block_view_alter().
*/
function MYTHEME_block_view_alter(&$data, $block) {
// Check we get the right menu block (side bar)
if ($block->bid == 'menu_block-1') {
// change the theme wrapper for the first level
$data['content']['#content']['#theme_wrappers'] = array('menu_tree__menu_block__1__level1');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment