如何在Magento

时间:2017-12-19 22:56:58

标签: php templates magento overwrite

我正在听这个答案,

https://[stackoverflow.com/questions/12936608/magento-howto-overwrite-one-template-file][1]

我试图覆盖的文件是,

应用程序/设计/前端/碱/默认/模板/客户/形式/ register.phtml

我将该文件复制到

应用程序/设计/前端/ myCompany的/默认/模板/客户/形式/ register.phtml

我设置,

系统 - >配置 - >设计 - > Package = mycompany

我冲洗了缓冲区并刷新了等等,但是

应用程序/设计/前端/碱/默认/模板/客户/形式/ register.phtml

仍在使用中。根据答案,这应该覆盖基本模板,但事实并非如此。我需要做些什么才能让Magento使用新的register.phtml?

2 个答案:

答案 0 :(得分:0)

我能够通过修改local.xml来实现这项工作,

<customer_account_login>
  <reference name="customer_form_login_1">
      <action method="setTemplate">
         <template>mycompany/login/login.phtml</template>
      </action>
      <block type="persistent/form_remember" name="persistent.remember.me" template="persistent/remember_me.phtml" />
      <block type="core/template" name="persistent.remember.me.tooltip" template="persistent/remember_me_tooltip.phtml" />
   </reference>

   <reference name="root">
     <action method="setTemplate"><template>page/new-login.phtml</template></action>
   </reference>

    <reference name="content">
       <block type="customer/form_login" name="customer_form_login_new" template="mycompany/login/login.phtml" />
    </reference>

    <reference name="customer_form_login">
       <remove name="persistent.remember.me"/>
       <remove name="persistent.remember.me.tooltip"/>
    </reference>

    <reference name="content">
       <remove name="customer_form_login"/>
    </reference>

</customer_account_login>

以下,

<customer_account_login>
    <reference name="customer_form_login_1">
        <action method="setTemplate"><template>mycompany/login/login.phtml</template></action>
    <action method="setTemplate"><template>mycompany/form/register.phtml</template></action>
    <block type="persistent/form_remember" name="persistent.remember.me" template="persistent/remember_me.phtml"/>
    <block type="core/template" name="persistent.remember.me.tooltip" template="persistent/remember_me_tooltip.phtml" />
       </reference>

   <reference name="root">
        <action method="setTemplate"><template>page/new-login.phtml</template></action>
    </reference>

    <reference name="content">
    <block type="customer/form_login" name="customer_form_login_new" template="mycompany/login/login.phtml" />
    <block type="customer/form_register" template="mycompany/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>

    <reference name="customer_form_login">
    <remove name="persistent.remember.me"/>
    <remove name="persistent.remember.me.tooltip"/>
    </reference>

    <reference name="customer_form_register">
    <remove name="persistent.remember.me"/>
    <remove name="persistent.remember.me.tooltip"/>
    </reference>

    <reference name="content">
    <remove name="customer_form_login"/>
    <remove name="customer_form_register"/>
    </reference>

</customer_account_login>

我将app / design / frontend / base / default / template / customer / form / register.phtml复制到app / design / frontend / base / default / template / mycompany / form / register.phtml。

答案 1 :(得分:0)

首先,您必须检查前端使用的包和主题,然后从

复制文件

app / design / frontend / base / default / template / customer / form / register.phtml到路径

应用程序/设计/前端/的 myCompany的/默认 /template/customer/form/register.phtml

(哪个包在前端使用。)