Ok so I've setup a new module to override the Contacts controller so that I can add a newsletter sign up option to it. My setup is as follows:
/app/code/local/MyNamespace/ContactsPlus/controllers/Contacts/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();
}
}
/app/code/local/MyNamespace/ContactsPlus/etc/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>
/app/etc/modules/MyNamespace_All.xml:
<?xml version="1.0"?>
<config>
<modules>
<MyNameSpace_ContactsPlus>
<active>true</active>
<codePool>local</codePool>
</MyNamespace_ContactsPlus>
</modules>
</config>
THe module appears in the admin modules list and it has produced the following error 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
That's this line:
$this->getLayout()->getBlock('contactForm')->setFormAction( Mage::getUrl('*/*/post') );
I'm not sure where to go from here though, a guess is that it can't set the form action on whatever is being returned from Mage::getUrl('//post') but I'm clutching at straws tbh.
Any help of advice would be greatly appreciated!