简体   繁体   中英

Adding new page layout - Magento

I created new xml layout, all phtmls needed for it and put the action method in controller but I can't get it working because url that is defined in controller doesn't point to new xml layout I made previously.

To be precise, I added my_password.xml into layout/account folder:

<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>

and added this into config.xml for Customer module:

        <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>

also added this to customer controller:

public function passwordupAction()
{
    $this->loadLayout();
    $this->_initLayoutMessages('customer/session');
    $this->_initLayoutMessages('catalog/session');

    $this->getLayout()->getBlock('head')->setTitle($this->__('My Password'));
    $this->renderLayout();
}

now mysite.com/index.php/customer/account/passwordup/ opens up but it isn't connected to my_password.xml layout, it opens some default layout.

Do you have some suggestions?

Thanks

Change this tag <customer_account_passwordup_index> to this one <customer_account_passwordup> .
The layout handle is built like this:

module_controller_action .
In your case the module is customer (by the way, don't modify the core...create a module for that), the controller name is account and the action name is passwordup .

Clear the cache and give it a go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM