magento用户登录后主页面的左侧菜单高亮显示
时间:2016-10-21 14:45来源:未知 作者:最模板 点击:次
magento 用户登录后主页面左侧菜单高亮显示,如下所示: 该实现一切归功于内置的Block: customer/account_navigation. 在layout文件(customer.xml)中,有如下声明: Xml代码 customer_account translate = label
magento用户登录后主页面左侧菜单高亮显示,如下所示:
该实现一切归功于内置的Block: customer/account_navigation.
在layout文件(customer.xml)中,有如下声明:
-
<customer_account translate="label">
-
<reference name="left">
-
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
-
<action method="addLink" translate="label" module="customer">
-
<name>account</name>
-
<path>customer/account/</path>
-
<label>Account Dashboard</label>
-
</action>
-
<action method="addLink" translate="label" module="customer">
-
<name>account_edit</name>
-
<path>customer/account/edit/</path>
-
<label>Account Information</label>
-
</action>
-
<action method="addLink" translate="label" module="customer">
-
<name>address_book</name>
-
<path>customer/address/</path>
-
<label>Address Book</label>
-
</action>
-
</block>
-
...
-
</reference>
-
...
-
</customer_account>
以上三个action标签声明了左侧三个菜单项,每当点击链接进入action的path对应的页面,自动会将该项设置为高亮。
现在进入某页面(引用了navigation) mycustomer/address后,希望能将高亮显示到前述菜单的Address Book项(链接为customer/address),则需要在controller的action方法中明确指定将其激活
-
if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')){
-
$navigationBlock->setActive('customer/address');
-
}
看看现在有什么变化? (责任编辑:最模板) |
------分隔线----------------------------