扩展Magento中的布局

时间:2011-09-06 03:55:24

标签: magento

我看过所有以前的问题,我知道我的问题没有重复。

请考虑以下背景:

我有一个布局:

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

这支持句柄(动作):

  • 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

如果我想再添加一个句柄:

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

如何添加更多句柄,如下所示:

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

我的问题是我在customer.xml布局中添加[default]文件。它会引起错误。我想这是因为扩展的文件不正确。

对我有什么想法?

更新

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

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

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>

1 个答案:

答案 0 :(得分:4)

您的问题是您在覆盖[default] \ default context中的文件时删除了customer.xml的其他处理程序。如果要覆盖不同主题文件夹中的文件,则必须记住将使用此文件而不是其他文件。

如果您只想使用此处理程序的文件,请将其添加到local.xml布局文件中(如果它不存在则创建它)