Silverstripe 中的一些菜单自定义

发布于 2024-08-29 13:16:03 字数 257 浏览 13 评论 0原文

1)我需要根据菜单行为每个菜单项设置不同的类名(迭代,我只需要一个数字)

<% control Menu(1) %>
<div class="mainmenu-item-$MenuItemRow"><a href="$Link">$MenuTitle</a></div>
<% end_control %>

2)有没有一种简单的方法来创建一个小的第二个菜单?

1) i need set different class name for every menu item, based on a menu row (iterating, i need just a number)

<% control Menu(1) %>
<div class="mainmenu-item-$MenuItemRow"><a href="$Link">$MenuTitle</a></div>
<% end_control %>

2) is there a simple way to create an small second menu ?

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

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

发布评论

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

评论(1

尘曦 2024-09-05 13:16:03
<% control Menu(1) %>
    <div class="mainmenu-item-$Pos"><a href="$Link">$MenuTitle</a></div>
<% end_control %>

http://doc.silverstripe.org/built-in-page-controls# dataobjectset_options

问题 2:

如果它只显示导航的另一个级别,您可以使用例如。 <%控制菜单(2)%>。也许这个帖子可以帮助您了解如何仅显示特殊项目: http://silverstripe.org/archive/显示/197044
还请考虑一下您的页面树中可能有用于子导航的菜单项的可能性,这些菜单项仅重定向到层次结构中其他位置的项目!所以你可以例如。在页面树中创建一个单独的“页脚”分支并使用:

<div class="footer">
    <% control ChildrenOf(footer) %>
        <span>
            <a href="$Link" title="Go To '$MenuTitle.XML'">$MenuTitle.XML</a>
        </span>
    <% end_control %>
</div>
<% control Menu(1) %>
    <div class="mainmenu-item-$Pos"><a href="$Link">$MenuTitle</a></div>
<% end_control %>

http://doc.silverstripe.org/built-in-page-controls#dataobjectset_options

Question 2:

if it should just show another level of your navigation you can use eg. <% control Menu(2) %>. And maybe this thread helps you about how to display only special items: http://silverstripe.org/archive/show/197044.
Think also of the possibility that you could have menu items in your page tree for you sub-navigation that are only redirects to items somewhere else in the hierarchy! So you could eg. create a seperate "Footer" branch in your page tree and use:

<div class="footer">
    <% control ChildrenOf(footer) %>
        <span>
            <a href="$Link" title="Go To '$MenuTitle.XML'">$MenuTitle.XML</a>
        </span>
    <% end_control %>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文