开发者

Extending Layout in Magento

I've look all previous questions, and I know that my question is not duplicated.

Please consider the below context:

I have a layout:

frontend\[base]\default\layout\customer.xml

This supports the handles (actions):

  • customer_account_index
  • customer_address_index
  • customer_address_view
  • customer_account_login
  • customer_account_logoutsuccess
  • customer_account_create
  • customer_account_forgotpassword
  • customer_account_confirmation
  • customer_account_edit

If I want to add one more handle:

frontend\[default]\default\layout\customer.xml
  • customer_account_active

How can I just add more handle like below:

<layout version="0.1.0">
    <customer_account_active>
    ...
    </customer_account_active>
</layout>

My problem is when I add customer.xml file in the [default] layout. It will rise the error. I guess that because of the file which is extended is incorrectly.

Any ideas for me?

Update:

frontend\[base]\default\layout\customer.xml is:

<layout version="0.1.0">
    <default>
        <!-- Mage_Customer -->
        <reference name="top.links">
            <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
        </reference>
    </default>

    <customer_logged_in>
        <reference name="top.links">
            <action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
        </reference>
    </customer_logged_in>
    <customer_logged_out>
        <!---<reference name="right">
            <block type="customer/form_login" name="customer_form_mini_login" before="-" template="customer/form/mini.login.phtml"/>
        </reference>-->
        <reference name="top.links">
            <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
        </reference>
        <remove name="wishlist_sidebar"></remove>
        <remove name="reorder"></remove>
    </customer_logged_out>
    <customer_account_login translate="label">
        <label>Customer Account Login Form</label>
        <!-- Mage_Customer -->
        <remove name="right"/>
        <remove name="left"/>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
        </reference>
    </customer_account_login>
    <customer_account_logoutsuccess translate="label">
        <label>Customer Account Logout Success</label>
        <!-- Mage_Customer -->
        <remove name="right"/>
        <remove name="left"/>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="core/template" name="customer_logout" template="customer/logout.phtml"/>
        </reference>
    </customer_account_logoutsuccess><customer_account_create translate="label">
        <label>Customer Account Registration Form</label>
        <!-- Mage_Customer -->
        <remove name="right"/>
        <remove name="left"/>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
                <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label">
                    <label>Form Fields Before</label>
                </block>
            </block>
        </reference>
    </customer_account_create>
    <customer_account_forgotpassword translate="label">
        <label>Customer Forgot Password Form</label>
        <remove name="right"/>
        <remove name="left"/>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="customer"><title>Password forgotten</title></action>
        </reference>
        <reference name="content">
            <!--<block type="core/template" name="forgotPassword" template="customer/form/forgotpassword.phtml"/>-->
            <block type="customer/account_forgotpassword" name="forgotPassword" template="customer/form/forgotpassword.phtml"/>
        </reference>
    </customer_account_forgotpassword>
    <customer_account_confirmation>
        <remove name="right"/>
        <remove name="left"/>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="customer"><title>Send confirmation link</title></action>
        </reference>
        <reference name="content">
            <block type="core/template" name="accountConfirmation" template="customer/form/confirmation.phtml"/>
        </reference>
    </customer_account_confirmation>
    <customer_account_edit translate="label">
        <label>Customer Account Edit Form</label>
        <update handle="customer_account"/>
        <reference name="root">
            <action method="setHeaderTitle" translate="title" module="customer"><title>Edit Account Info</title></action>
        </reference>
        <reference name="my.account.wrapper">
            <block type="customer/form_edit" name="customer_edit" template="customer/form/edit.phtml"/>
        </reference>
        <reference name="left">
          <action method="unsetChild"><name>left.permanent.callout</name></action>
        </reference>
    </customer_account_edit>
    <customer_account translate="label">
        <label>Customer My Account (All Pages)</label>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="page/html_wrapper" name="my.account.wrapper" translate="label">
                <label>My Account Wrapper</label>
                <action method="setElementClass"><value>my-开发者_运维技巧account</value></action>
            </block>
        </reference>
        <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>
            <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml">
                <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
            </block>
            <block type="catalog/product_compare_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
            <block type="sales/reorder_sidebar" name="sale.reorder.sidebar" as="reorder" template="sales/reorder/sidebar.phtml"/>
            <remove name="tags_popular"/>
        </reference>
    </customer_account>
    <customer_account_index translate="label">
        <label>Customer My Account Dashboard</label>
        <update handle="customer_account"/>
        <!-- Mage_Customer -->
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </reference>
        <reference name="my.account.wrapper">
            <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">
                <block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
                <block type="core/template" name="customer_account_dashboard_top" as="top" />
                <block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
                <block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
                <block type="customer/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
            </block>
        </reference>
    </customer_account_index>
    <customer_address_index translate="label">
        <label>Customer My Account Address Book</label>
        <!-- Mage_Customer -->
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
            <block type="customer/address_book" name="address_book" template="customer/address/book.phtml"/>
        </reference>
    </customer_address_index>
    <customer_address_form translate="label">
        <label>Customer My Account Address Edit Form</label>
        <!-- Mage_Customer -->
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
            <block type="customer/address_edit" name="customer_address_edit" template="customer/address/edit.phtml"/>
        </reference>
    </customer_address_form>        
</layout>

And frontend\[default]\default\layout\customer.xml:

<layout version="0.1.0">    
    <customer_account_active>
        <remove name="right"/>
        <remove name="left"/>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="customer"><title>Send confirmation link</title></action>
        </reference>
        <reference name="content">
            <block type="customer/form_active" name="accountActive" as="accountActive" template="customer/account/active.phtml"/>
        </reference>
    </customer_account_active>
</layout>


Your issue is that you are removing other handlers for your customer.xml while overwriting the file in [default]\default context. If you are overwriting the file in different theme folder you have to remember that this file will be used and not the others.

If you want a file only with this handler then add this to local.xml layout file instead (create it if it does not exist)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜