问题描述
如何更改默认的Silverstripe主题简单,以便在单击子菜单(在侧栏上)时,通过$ Breadcrumbs将其替换为面包屑。单击菜单1的示例,显示侧边栏
How do I change the default Silverstripe theme 'Simple' so that when a submenu (on the sidebar) is clicked the sidebar menu is replaced by a breadcrumb via $Breadcrumbs. Example when Menu1 is clicked, the sidebar is shown
Menu1 Menu2 Menu3
菜单1(不可单击,仅是标题)
SubMenu1
SubMenu2
Menu1 (not clickable, just a title) SubMenu1 SubMenu2
但是当单击SubMenu1或SubMenu2时,整个边栏消失,并显示$ Breadcrumbs。
but when either SubMenu1 or SubMenu2 is clicked entire sidebar dissapears and a $Breadcrumbs is shown.
Menu1 Menu2 Menu3
菜单1->子菜单1
$内容
Menu1-->SubMenu1 $Content
因此,当单击面包屑上的菜单1时,它将返回到菜单1。
Therefore when Menu1 on Breadcrumb is clicked, it goes back to Menu1.
推荐答案
首先,为什么要实现这一点?我在这里看不到真正的好处,但是如果您真的需要这个,那么这可能是一个答案:
First of all, why do you want to achieve this? I can't see a real benefit out here, but if you really need this, so this could be possible an answer:
1)如果您使用的是 $ Menu(1)
级仅显示 $ MenuTitle.XML
(或仅显示 $ Title
,它们几乎是相同的)
1) If you are on the $Menu(1)
level show only $MenuTitle.XML
(or just $Title
, they're almost the same)in the sidebar
2)其他如果您在 $ Menu(2)
或深于(2)
级别显示面包屑
2) Else If you are on the $Menu(2)
or deeper than (2)
level show breadcrumbs
您可以通过选中
<% if $Menu(1) %>
<!-- Here you print only titles-->
<% loop $Menu(1) %>
<a href="$Link">$MenuTitle.XML</a>
<% end_loop %>
<% else %>
<!-- Here you print out the BreadCrumbs, only if you are deeper than 1st level menu -->
<% include $BreadCrumbs %>
<% end_if %>
此处检查您是否位于第一级,然后仅显示带有链接,则如果您位于子页面上,则显示面包屑
Here you check if you are on first level then display only titles with links, then if you are on the subpage display the BreadCrumbs
这篇关于Silverstripe菜单,子菜单和面包屑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!