Skip to content

Instantly share code, notes, and snippets.

@nguyenthanhxuan
Forked from gagarine/template.tpl.php
Last active August 29, 2015 14:21
Show Gist options
  • Save nguyenthanhxuan/b99f2984ac318b17fefe to your computer and use it in GitHub Desktop.
Save nguyenthanhxuan/b99f2984ac318b17fefe 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