如何突出显示当前页面的父级? [英] How to highlight parent of the current page?

查看:64
本文介绍了如何突出显示当前页面的父级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何突出显示当前页面的父菜单项?

How can I hightlight the parent menu item of the current page?

我的站点地图如下:

 val siteMap = SiteMap(
      Menu("Home") / "index",
      Menu("Search") / "search" submenus (
          Menu("Search Results") / "search-results") >> Hidden)

我将其使用如下:

<lift:Menu.builder ul:class="tabs" li_item:class="selected"  />

但是,当我导航到/search-results 时-不再选择 search 菜单项(即,已选择 css类不再应用.)

However, when I navigate to the /search-results - the search menu item is no longer selected (i.e. the css class selected is no longer applied to it).

有什么提示吗?

推荐答案

这很简单.您应该使用Lift内置代码段菜单参数 li_path

it's quite simple. You should use Lift built-in snippet Menu parameter li_path

文档中的内容

li_path-添加指定的属性 到当前页面的痕迹 (面包屑路径是 是直接祖先的菜单项 在菜单树中)

li_path - Adds the specified attribute to the current page’s breadcrumb trail (the breadcrumb trail is the set of menu items that are direct ancestors in the menu tree)

因此在您的代码中,您可以执行以下操作:

so in your code, you could do just:

<lift:Menu.builder ul:class="tabs" li_item:class="selected" li_path:class="selected" />

希望这会有所帮助.如果您还有其他问题,请问:)

Hope this helps. If you could have any other questions just ask :)

这篇关于如何突出显示当前页面的父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆