3

I am new to magento. I have override the Contact form, but in home page not displaying the Contacts link.

my code is:

etc\module\Easylife_Contacts.xml

     <?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Contacts>
            <active>true</active>
            <codePool>local</codePool>
        </Easylife_Contacts>
    </modules>
</config>

magento\app\code\local\Easylife\Contacts\controllers\IndexController.php

<?php
include_once('Mage/Contacts/controllers/IndexController.php');

class Easylife_Contacts_IndexController extends Mage_Contacts_IndexController
{

    const XML_PATH_EMAIL_RECIPIENT  = 'contacts/email/recipient_email';
    const XML_PATH_EMAIL_SENDER     = 'contacts/email/sender_email_identity';
    const XML_PATH_EMAIL_TEMPLATE   = 'contacts/email/email_template';
    const XML_PATH_ENABLED          = 'contacts/contacts/enabled';

    public function preDispatch()
    {
        parent::preDispatch();

        if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
            $this->norouteAction();
        }
    }

    public function indexAction()
    {
        $this->loadLayout();
        $this->getLayout()->getBlock('contactForm')
            ->setFormAction( Mage::getUrl('*/*/post') );

        $this->_initLayoutMessages('customer/session');
        $this->_initLayoutMessages('catalog/session');
        $this->renderLayout();
    }

    public function postAction()
    {
        ....
    }

}

magento\app\code\local\Easylife\Contacts\etc\config.xml

<?xml version="1.0" encoding="utf-8"?>

<config>
    <modules>
        <Easylife_Contacts>
            <version>0.1.0</version>
        </Easylife_Contacts>
    </modules>
    <frontend>
        <routers>
            <contacts>
                <args>
                    <modules>
                        <Easylife_Contacts before="Mage_Contacts">Easylife_Contacts</Easylife_Contacts>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
     <layout>
        <updates>
            <contacts>
                <file>contacts.xml</file>
            </contacts>
        </updates>
    </layout>
</config>

magento\app\design\frontend\easylife\default\layout\contacts.xml

<?xml version="1.0"?>

<layout version="0.1.0">

    <contacts_index_index translate="label">

        <reference name="content">
            <block type="core/template" name="contactForms" template="contacts/form.phtml"/>
        </reference>

        <update handle="contactForm"></update>
    </contacts_index_index>
</layout>

magento\app\design\frontend\easylife\default\template\contacts\form.phtml

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="page-title">
    <h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
</div>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
  ....
</form>
<script type="text/javascript">
//<![CDATA[
    var contactForm = new VarienForm('contactForm', true);
//]]>
</script>

Can anyone tell me where I went wrong?

thanks.

  • you want to get contact us link in header and footer? – MeenakshiSundaram R Feb 19 '14 at 13:28
  • @MeenakshiSundaramR, footer only. – Magento Nav Feb 19 '14 at 13:32
2
<default>
        <reference name="footer_links">
            <action method="addLink" translate="label title" module="contacts"><label>Contact Us</label><url>contacts</url><title>Contact Us</title></action>
        </reference>
    </default>

Add this code in your layout file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.