Reputation: 330
I'm trying to develop my own magento module, and I got an issue with the xml layout file I want to override. I'm working on a way to personalize the login form, from /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 contains these 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 suppose to be my xml layout file) is the following one :
<?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>
On my block, IT_CustomerCar_Block_Customer_Form_Login, I add this line return $html . 'block';
to check if it is indeed called. And it is. There is a "block" string 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 the one from the core.
edit: I also add a var_dump($this->getTemplate());
on my _toHtml methode from the Block class. And it shows that line : string(36) "persistent/customer/form/login.phtml"
. I don't really understand why btw. I expected "/customer/form/login.phtml", and not the one from the "persistent" folder.
I guess I'm missing something obvious, but I tried to follow a lot of advices from forums and tutorials without any success. This problem seems to be very common, and I thought I could fix it quick. I was wrong... I hope you'll be able to help me,
Thanks :)
I manage to fix that, with the dagfr answer.
First, I disable the persistent module from the backend and the /app/etc/modules/Mage_Persistent.xml
.
Then, I change my customercar.xml file for
<customer_account_login>
<reference name="customer_form_login">
<action method="setTemplate"><template>customercar/form/login.phtml</template></action>
</reference>
Upvotes: 4
Views: 8722
Reputation: 2384
1) You must remove the persistent thing, it will not help finding problem as it's not using the right template.
2) The change you made, will make the yoursite.com/customercar/account/login page using your template but not the yoursite.com/customer/account/login page. Is it what you need ?
3) you use :
<block type="core/template" name="customercar_form_login" output="toHtml" template="customercar/form/login.phtml" ></block>
This is not supposed to be a core/template block but the customer/form_login block (overwritten by your block).
4) you change its name, so it won't be called if you don't have a getChildHtml in the right file.
To sum up, you should do it this way :
<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 login block (the overwritten one) use your new template in the original page
Upvotes: 4