Adjustment of Magento XML File

I am trying to develop my own magento module and I have a problem with the xml layout file that I want to override. I am working to personalize the login form with / customer / account / login.

For this purpose I have the following files

app/ etc/ modules/ - IT_CustomerCar.xml code/ local/ IT/ CustomerCar/ Block/ Customer/ From/ Login.php controllers/ - AccountController.php etc/ - config.xml design/ frontend/ base/ default/ layout/ - customercar.xml template/ customercar/ form/ - login.phtml' 

My goal is to override the /design/frontend/base/default/layout/customer.xml file to personalize the login form.

Now, to be more specific about my files

The config.xml file contains the following lines:

 <config> <modules> <it_customercar> <version>0.1.0</version> </it_customercar> </modules> <global> <rewrite> <it_customercar_customer_account> <from><![CDATA[#^/customer/account/#]]> </from> <to>/customercar/account/</to> </it_customercar_customer_account> </rewrite> <blocks> <customer> <rewrite> <form_login>IT_CustomerCar_Block_Customer_Form_Login</form_login> </rewrite> </customer> <helpers> <customercar> <class>It_CustomerCar_Helper</class> </customercar> </helpers> </blocks> </global> <frontend> <routers> <it_customercar> <use>standard</use> <args> <module>IT_CustomerCar</module> <frontName>customercar</frontName> </args> </it_customercar> </routers> <layout> <updates> <it_customercar> <file>customercar.xml</file> </it_customercar> </updates> </layout> </frontend> 

My customercar.xml (which is supposedly my xml layout file) is as follows:

 <?xml version="1.0"?> <layout version="0.1.0"> <default> </default> <customercar_account_login> <label>MODULE : Customer Account Login Form</label> <reference name="content"> <block type="core/template" name="customercar_form_login" output="toHtml" template="customercar/form/login.phtml" ></block> </reference> </customercar_account_login> </layout> 

In my block, IT_CustomerCar_Block_Customer_Form_Login, I add this line return $html . 'block'; return $html . 'block'; to check if it is really caused. And this. There is a "block" line just below my login form, as expected.

On the other hand, the customercar.xml file seems to be ignored. I used the Allan Storm LayoutViewer module to check my page, and the layout is still one of the main ones.

edit: I also add var_dump($this->getTemplate()); to my _toHtml method from the Block class. And that shows that line: string(36) "persistent/customer/form/login.phtml" . I really don't understand why by the way. I was expecting "/customer/form/login.phtml" and not the one from the "permanent" folder.

I think I am missing something obvious, but I tried to follow the advice and advice without any success. This problem seems very common, and I thought I could fix it quickly. I was wrong ... I hope you can help me,

Thanks:)

Decision

I manage to fix this with dagfr answer.

First, I will disable the persistent module from the backend and /app/etc/modules/Mage_Persistent.xml .

Then I modify my customercar.xml file to

 <customer_account_login> <reference name="customer_form_login"> <action method="setTemplate"><template>customercar/form/login.phtml</template></action> </reference> 

+4
source share
1 answer

1) You must remove the permanent thing, this will not help to find the problem, because it does not use the correct template.

2) A change you make will make yoursite.com/customercar/account/login page using your template, but not yoursite.com/customer/account/login page. That's what you need?

3) you use:

 <block type="core/template" name="customercar_form_login" output="toHtml" template="customercar/form/login.phtml" ></block> 

This should not be the core / template, but the customer / form_login block (overwritten by your block).

4) you change your name, so it will not be called if you do not have the getChildHtml file in the desired file.

To summarize, you should do it as follows:

 <customer_account_login> <reference name="customer_form_login"> <action method="setTemplate"><template>customercar/form/login.phtml</template></action> </reference> </customer_account_login> 

This will say that the registration block (rewritten) uses your new template on the original page

+4
source

All Articles