0

我正在尝试向 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);
}

虽然,这似乎永远不会被调用。我究竟做错了什么?

4

1 回答 1

1

我在 template.php 中添加了以下函数,并在页面模板中调用它或 render($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;
}
于 2013-07-27T08:19:10.520 回答