【问题标题】:Create an "actIve" state for static Magento nav为静态 Magento 导航创建“活动”状态
【发布时间】:2012-05-11 16:19:32
【问题描述】:

我在 header.phtml 文件中创建了一个静态导航菜单。

<li><a href="/about.html"> about</a></li> <li><a href="/store.html">store</a></li> 等..

如果页面处于活动状态,如何将“活动”类添加到列表项?

谢谢, -山姆

【问题讨论】:

    标签: css magento content-management-system navigation


    【解决方案1】:

    Magento 的内置方法在导航块类中:

    isCategoryActive($category)
    

    不过,您应该能够检查它,因为您已将模板更改为静态导航,我猜您没有使用正确的模型来调用该函数。

    【讨论】:

    • 你说得对,我没有使用 Magento 的内置导航系统。这只是一个静态列表。
    【解决方案2】:

    旧帖子,但仍可能对某人有所帮助:

    $url = $category->getUrl();     
    if (strpos(Mage::helper('core/url')->getCurrentUrl(),$url) !== false ) {
        $html .= ' <em>&gt;</em>'; // highlight
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多