drupal多级顶部导航

发布于 2024-10-08 02:42:28 字数 381 浏览 1 评论 0原文

我是 drupal 的新手,但我对 php 和 html/css 有很好的了解。 我有这个 drupal 站点,其中主菜单有 2 个级别。

在主题的 page.tpl.php 中可以看到这一行:

<div class="pr-menu">
  <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
</div>

$primary_links 变量似乎只保存一个包含第一级菜单项的数组。 现在我的问题是:将整个主菜单加载为无序列表而不是现在显示的第一级主链接的最佳方法是什么?

i'm new to drupal, but i have a good knowledge about php, and html/css.
I have this drupal site where the primary menu has 2 levels.

In the page.tpl.php of the theme is see this line:

<div class="pr-menu">
  <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
</div>

the $primary_links variable seems to only hold an array with the first level menu items.
Now my question is: what is the best way to load the entire primary menu as an unordered list in stead of the first level primary links that are displayed now?

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

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

发布评论

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

评论(2

软的没边 2024-10-15 02:42:28

很好,请参阅此处的 Drupal 6 代码,我相信它还会注意设置为主菜单源的内容(在 /admin/build/menu/settings 中):

http://drupal.org/node/68578

Nice, see the Drupal 6 code here, I believe it will also pay attention to what is set as the primary menu source (in /admin/build/menu/settings ):

http://drupal.org/node/68578

小情绪 2024-10-15 02:42:28

在查看了 menu.inc 中的现有函数之后,终于找到了某种解决方案

对于任何感兴趣的人,这里是放入主题的 page.tpl.php 文件中的代码,而不是默认的主链接代码:

<div class="pr-menu">
  <?php print menu_tree('primary-links'); ?>
</div>

menu_tree() 将以多级 html 列表的形式返回主菜单,其中包含可通过 css 类访问的所有最重要的属性(第一个、最后一个、活动的……)。

Finally found some kind of solution, after looking a bit trough the existing functions in menu.inc

For anyone interested, here is the code to put in your theme's page.tpl.php file, instead of the default primary link code:

<div class="pr-menu">
  <?php print menu_tree('primary-links'); ?>
</div>

menu_tree() will return the primary menu as a multi level html-list with all the most important properties (first, last, active,...) accessible trough css classes.

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