我正在尝试向drupal7的主要标签元素添加两个类。我尝试通过将它添加到我的template.php来覆盖theme_menu_local_tasks:
function {{proj}}_menu_local_tasks(&$variables) {
$output = '';
if (!empty($variables['primary'])) {
$variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
$variables['primary']['#prefix'] .= '<ul class="nav nav-tabs">';
$variables['primary']['#suffix'] = '</ul>';
$output .= drupal_render($variables['primary']);
}
if (!empty($variables['secondary'])) {
$variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
$variables['secondary']['#prefix'] .= '<ul class="nav nav-tabs">';
$variables['secondary']['#suffix'] = '</ul>';
$output .= drupal_render($variables['secondary']);
}
return theme_menu_local_tasks($variables);
}
虽然,这似乎永远不会被称为。我做错了什么?
答案 0 :(得分:1)
我在template.php中添加了以下函数,并在页面模板中调用它或渲染($ tabs):
function {{proj}}_render_nav_tabs() {
$output = '';
if ($primary = menu_primary_local_tasks()) {
$output .= '<ul class="nav nav-tabs space-bottom">' . drupal_render($primary) . '</ul>';
}
if ($secondary = menu_secondary_local_tasks()) {
$output .= '<ul class="nav nav-tabs space-bottom">' . drupal_render($secondary) .'</ul>';
}
return $output;
}