我创建了新的xml布局,所有的phtmls需要它,并把动作方法在控制器中,但我不能得到它的工作,因为在控制器中定义的url不指向新的xml布局我以前。
确切地说,我将my_password.xml添加到layout/account文件夹中:
<customer_account_passwordup_index>
<update handle="customer_account"/>
<reference name="root">
<action method="setTemplate"><template>page/my_account_page.phtml</template></action>
</reference>
<reference name="my.account.wrapper">
<block type="customer/account_password" name="customer.account.password.update" template="customer/account/password_update.phtml"/>
</reference>
</customer_account_passwordup_index>
<customer_account>
<reference name="customer_account_navigation" >
<action method="addLink" translate="label" module="customer"><name>password_update</name><path>customer/account/passwordup</path><label>My Password</label></action>
</reference>
</customer_account>
<customer_account>
<reference name="header">
<action method="setTemplate">
<template>page/html/customer_account_header.phtml</template></action>
</reference>
</customer_account>
并将其添加到客户模块的config.xml中:
<updates>
<customer module="Mage_Customer">
<file>customer.xml</file>
</customer>
<customer_account_passwordup module="Mage_Customer">
<file>account/my_password.xml</file>
</customer_account_passwordup>
</updates>
还将此添加到客户控制器:
public function passwordupAction()
{
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
$this->getLayout()->getBlock('head')->setTitle($this->__('My Password'));
$this->renderLayout();
}
现在mysite.com/index.php/customer/account/passwordup/打开了,但它没有连接到my_password.xml布局,它打开了一些默认的布局。
你有什么建议吗?
谢谢
将标签<customer_account_passwordup_index>
改为<customer_account_passwordup>
。
布局句柄是这样构建的:
module_controller_action
.
在您的情况下,模块是customer
(顺便说一下,不要修改核心…创建一个模块),控制器名称为account
,操作名称为passwordup
。