I'm trying to create two separate registration pages. They need to be in their own model because one of the design requirements is having separate .phtml files.
I have Magento 1.9 CE.
I started by creating a new module, complete with its own template, layout, block, configuration and controller, and it worked without any problem.
The I tried extending the Account Controller using the same module, following many tutorials which all talk about the same thing, but for some reason neither overriding of the indexAction is working, nor I'm able to call my new methods. I just get 404.
Here's the code:
Code_PS.xml in /app/etc/modules
<?xml version="1.0"?>
<config>
<modules>
<Code_PS>
<active>true</active>
<codePool>local</codePool>
</Code_PS>
</modules>
</config>
code_ps.xml in /app/design/frontend/ps/marketplace/layout/
<?xml version="1.0"?>
<layout>
<ps_account_registerimpressionist translate="label" module="ps">
<label>Custom form</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action><!-- can be different -->
</reference>
<reference name="content">
<block type="core/template" name="ps" template="code_ps/registerimpressionist.phtml" /><!-- content of page -->
</reference>
</ps_account_registerimpressionist>
<ps_account_registersponsor translate="label" module="ps">
<label>Custom form</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action><!-- can be different -->
</reference>
<reference name="content">
<block type="core/template" name="ps" template="code_ps/registersponsor.phtml" /><!-- content of page -->
</reference>
</ps_account_registersponsor>
<code_ps_customer_account_index>
<update handle="customer_account_index"/>
</code_ps_customer_account_index>
</layout>
config.xml from /app/code/local/Code/PS/etc/
<?xml version="1.0"?>
<config>
<modules>
<Code_PS>
<version>0.2.0</version>
</Code_PS>
</modules>
<frontend>
<routers>
<customer>
<use>standard</use>
<args>
<modules>
<Code_PS before="Mage_Customer">
Code_PS
</Code_PS>
</modules>
</args>
</customer>
</routers>
<layout>
<updates>
<code_ps>
<file>code_ps.xml</file><!-- frontend layout file -->
</code_ps>
</updates>
</layout>
</frontend>
</config>
and finally, AccountController.php from /app/code/local/Code/PS/controllers/
<?php
require_once 'Mage/Customer/controllers/AccountController.php';
class Code_PS_AccountController extends Mage_Customer_AccountController
{
public function indexAction()
{
//no custom codes.
//parent::indexAction();
}
public function registerimpressionistAction(){
if ($this->_getSession()->isLoggedIn()) {
$this->_redirect('*/*');
return;
}
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->renderLayout();
}
public function registersponsorAction(){
$this->loadLayout();
$this->_initLayoutMessages('core/session'); //this will allow flash messages
$this->renderLayout();
}
}
}
any help would be appreciated
Best Answer
Issue1: Spacing issue
In config.xml
Please put this code in one line:
Like:
Layout file not working:
May be layout update is not working: you need to remove code from config.xml.Need to put codes of codes_ps code at local.xml or customer.xml.
Remove:
preDispatch function:
As per as magento system,
before any action
ofAccountController
dispatch
magento ischeck check it valued or not
.So you need to add your action to dispatch event.Code: