Step1: you need to creat a XML file same at location given below, if folder does not exist please create it
/app/etc/modules/MageWorks_Contact.xml
and paste the content below in MageWorks_Contact.xml
true
local
Step 2: Now create Confix.xml at the location below
app/code/local/MageWorks/Contact/etc/config.xml
and paste the content below to config.xml file
0.1.0
MageWorks_Contact
MageWorks_Contact
Step 3: Now create controller at the folloing location
app/code/local/MageWorks/Contact/controllers/IndexController.php
now paste the content below to controller
class MageWorks_Contact_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
//Get current layout state
$this->loadLayout();
$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'mageworks.contact',
array(
'template' => 'mageworks/contact.phtml'
)
);
$this->getLayout()->getBlock('content')->append($block);
//$this->getLayout()->getBlock('right')->insert($block, 'catalog.compare.sidebar', true);
$this->_initLayoutMessages('core/session');
$this->renderLayout();
}
public function sendemailAction()
{
//Fetch submited params
$params = $this->getRequest()->getParams();
$mail = new Zend_Mail();
$mail->setBodyText($params['comment']);
$mail->setFrom($params['email'], $params['name']);
$mail->addTo('somebody_else@example.com', 'Some Recipient');
$mail->setSubject('Test MageWorks_Contact Module for Magento');
try {
$mail->send();
}
catch(Exception $ex) {
Mage::getSingleton('core/session')->addError('Unable to send email. Sample of a custom notification error from MageWorks_Contact.');
}
//Redirect back to index action of (this) mageworks-contact controller
$this->_redirect('mageworks-contact/');
}
}
Step 4: Create view
app/design/frontend/default/default/template/mageworks/contact.phtml
paste content below to contact.phtml
my question is: how to call this form from a button?
ReplyDeletemake sure you'll replace with
ReplyDeleteand with
or It will throw a 404 error with your custom module