Drupal 7 双行菜单

发布于 2024-11-09 02:29:02 字数 481 浏览 0 评论 0原文

我正在使用 Drupal 7 开发一个网站。我已经正确设置了菜单和所有这些内容的样式。问题出在二级菜单上。

我的想法是在第一个菜单后面立即创建第二个菜单,例如:

MENU_ITEM1 |菜单项2 |菜单项3 |菜单_ITEM4

菜单_ITEM1_SUBITEM1 |菜单_项目1_SUBITEM2 | MENU_ITEM1_SUBITEM3

结构如下:

  • MENU_ITEM1
    • MENU_ITEM1_SUBITEM1
    • MENU_ITEM1_SUBITEM2
    • MENU_ITEM1_SUBITEM3
  • MENU_ITEM2
  • MENU_ITEM3
  • MENU_ITEM4

第一个问题,我看不到次要项目 2. 关于如何创建这个有什么建议吗?

多谢!

I am developing a site with Drupal 7. I have styled the menu correctly and all this stuff. The problem is with the secondary menu.

My idea is to create the second menu immediatly behind the first menu, for example:

MENU_ITEM1 | MENU_ITEM2 | MENU_ITEM3 | MENU_ITEM4

MENU_ITEM1_SUBITEM1 | MENU_ITEM1_SUBITEM2 | MENU_ITEM1_SUBITEM3

And the structure goes like this:

  • MENU_ITEM1
    • MENU_ITEM1_SUBITEM1
    • MENU_ITEM1_SUBITEM2
    • MENU_ITEM1_SUBITEM3
  • MENU_ITEM2
  • MENU_ITEM3
  • MENU_ITEM4

1st problem, I cannot see secondary items
2nd Any suggestion on how to create this?

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴骨ら 2024-11-16 02:29:02

您可以在 drupal 中构建具有多个级别的菜单,并选择该菜单(例如主菜单)作为您的主链接辅助链接,位于“/admin/struction/menu/settings”

然后,您可以在 template.php 文件中实现 drupal 的 theme_preprocess_page() 函数:

function themeName_preprocess_page(&$vars) {
    if (isset($vars['main_menu'])) {
        $vars['primary_links'] = theme('links__system_primary_menu', array(
            'links' => $vars['main_menu'],
        ));
    }
    else {
        $vars['primary_links'] = false;
    }

    if (isset($vars['secondary_menu'])) {
        $vars['secondary_links'] = theme('links__system_secondary_menu', array(
            'links' => $vars['secondary_menu'],
        ));
    }
    else {
        $vars['primary_links'] = false;
    }
}

现在您需要做的就是回显/打印新变量 ($primary_links< /code> 和 $secondary_links 在本例中)现在可用于 page.tpl.php

You can structure your menu with multiple levels within drupal, and select that menu (e.g. main menu) as the source for both your main links and secondary links, over at "/admin/structure/menu/settings".

Then you can implement drupal's theme_preprocess_page() function in your template.php file:

function themeName_preprocess_page(&$vars) {
    if (isset($vars['main_menu'])) {
        $vars['primary_links'] = theme('links__system_primary_menu', array(
            'links' => $vars['main_menu'],
        ));
    }
    else {
        $vars['primary_links'] = false;
    }

    if (isset($vars['secondary_menu'])) {
        $vars['secondary_links'] = theme('links__system_secondary_menu', array(
            'links' => $vars['secondary_menu'],
        ));
    }
    else {
        $vars['primary_links'] = false;
    }
}

Now all you need to do is echo/print the new variables ($primary_links & $secondary_links in this case) now available to page.tpl.php.

似梦非梦 2024-11-16 02:29:02

并非所有 drupal 主题都允许您像这样设置菜单样式。

如果您的主题支持嵌套菜单结构,则只需将菜单项嵌套在菜单设置中即可。幸运的是,由于拖放界面,drupal 可以很好地处理这个问题,您只需要确保任何顶级菜单项都选中了“扩展”框即可。

如果您想查看一个简单的示例,您可以查看“导航”菜单设置,它们已经嵌套和展开,因此您会知道主菜单设置应该是什么样子。

Not all drupal themes allow you to style your menus like this.

If you have a theme that supports nested menu structures, you just need to nest your menu items in the menu settings. Fortunately, drupal handles this relatively well thanks to the drag and drop interface, you just need to make sure that any of your top level menu items have the "expanded" box checked.

If you would like to see a quick example, you can just look at your "navigation" menu settings, they are already nested and expanded, so you'll know what your main menu settings should look like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文