questions

0 Answers

Facing problem with contacts controller while overriding in Magento 1.6.2

Asked by: SamBaker 4224 views , , ,
Questions

So, I have made setup a brand new module to overrule the Contacts organizer to ensure that I’m able to give a newsletter registration choice to it. Following is the setup made by me:

Following is the code for IndexController.php:
<?php
# Controllers are not autoloaded so we will have to do it manually:
require_once ‘Mage/Contacts/controllers/IndexController.php’;
class MyNameSpace_ContactsPlus_Contacts_IndexController extends Mage_Contacts_IndexController
{
    # Overloaded indexAction
    public function indexAction() {
        # Just to make sure
        error_log(‘Yes, I did it!’);
        parent::indexAction();
    }
}

Following is the code for config.xml:
<?xml version=”1.0″?>
<config>
    <modules>
        <mynamespace_ContactsPlus>
            <version>0.1.0</version>
        </mynamespace_ContactsPlus>
    </modules>
    <global>
        <rewrite>
            <mynamespace_contactsplus_contacts_index>
                <from><![CDATA[#^/contacts/index/#]]></from>
                <to>/contactsplus/contacts_index/</to>
            </mynamespace_contactsplus_contacts_index>
            <mynamespace_contactsplus_contacts_index>
                <from><![CDATA[#^/contacts/#]]></from>
                <to>/contactsplus/contacts_index/</to>
            </mynamespace_contactsplus_contacts_index>           
        </rewrite>
    </global>
    <frontend>
        <routers>
            <mynamespace_contactsplus>
                <use>standard</use>
                <args>
                    <module>mynamespace_ContactsPlus</module>
                    <frontName>contactsplus</frontName>
                </args>
            </mynamespace_contactsplus>
        </routers>
    </frontend>   
</config>

Following is the code for MyNamespace_All.xml:
<?xml version=”1.0″?>
<config>
<modules>
    <MyNameSpace_ContactsPlus>
        <active>true</active>
        <codePool>local</codePool>
    </MyNamespace_ContactsPlus>
</modules>
</config>

The module seems within the admin modules list and contains created the error as follows on my /contacts/ page:
Fatal error: Call to a member function setFormAction() on a non-object in /srv/www/foo.com/app/code/core/Mage/Contacts/controllers/IndexController.php on line 54

Following is the line:
$this->getLayout()->getBlock(‘contactForm’)->setFormAction( Mage::getUrl(‘*/*/post’) );

I am unsure what to do came from here however, an estimate is it cannot set the method action on whatsoever has been the output from Mage::getUrl(‘//post’) but I am holding at straws tbh.

Any assistance of advice could be highly appreciated!

Answer Question