【问题标题】:drupal 7 active menu item is set for multiple menu links with contextual filterdrupal 7活动菜单项设置为具有上下文过滤器的多个菜单链接
【发布时间】:2016-11-25 08:46:40
【问题描述】:

我的菜单中有 3 个页面基本上链接到同一个页面,但在它们上使用了不同的上下文过滤器。

有什么方法可以在我的菜单中只将正确的“页面”设置为活动页面,这样其他链接就不会获得活动菜单项样式?

这些是链接:

  • xxx.ons-aanbod/%(上下文过滤器)
  • xxx.ons-aanbod/diversiteit (VOORGROEPEN)
  • xxx.ons-aanbod/architectuur (VOOR SCHOLEN)

【问题讨论】:

    标签: drupal menu drupal-7 drupal-contextual-filters


    【解决方案1】:

    我不确定,但我认为你可以像这样挂钩菜单链接:

    function MODULENAME_menu_link_alter(&$item)
    {
        $path = current_path(); // get path of current page displayed
        if($item['link_path']== $path) // or something like
        {
            // add class active
        }
    }
    

    https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_link_alter/7.x

    https://api.drupal.org/api/drupal/includes%21path.inc/function/current_path/7.x

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多