用户登录后主页面左侧菜单高亮显示,如下所示:
[img]http://dl.iteye.com/upload/attachment/239294/a7deba47-2371-3e77-b2af-e18768fb5cac.jpg[/img]
该实现一切归功于内置的Block: customer/account_navigation.
在layout文件(customer.xml)中,有如下声明:
以上三个action标签声明了左侧三个菜单项,每当点击链接进入action的path对应的页面,自动会将该项设置为高亮。
现在进入某页面(引用了navigation) mycustomer/address后,希望能将高亮显示到前述菜单的Address Book项(链接为customer/address),则需要在controller的action方法中明确指定将其激活
看看现在有什么变化?
[img]http://dl.iteye.com/upload/attachment/239294/a7deba47-2371-3e77-b2af-e18768fb5cac.jpg[/img]
该实现一切归功于内置的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');
}
看看现在有什么变化?