Value not getting bind in the Magento controller -
this predefined post function inside magento controller.
public function postaction() { $post = $this->getrequest()->getpost(); if ( $post ) { $translate = mage::getsingleton('core/translate'); /* @var $translate mage_core_model_translate */ $translate->settranslateinline(false); try { $postobject = new varien_object(); $postobject->setdata($post); $error = false; if (!zend_validate::is(trim($post['name']) , 'notempty')) { $error = true; } if (!zend_validate::is(trim($post['comment']) , 'notempty')) { //$error = true; //orignal code $error = false; } if (!zend_validate::is(trim($post['email']), 'emailaddress')) { $error = true; } mage::log($post['producturl']); if (!zend_validate::is(trim($post['producturl']) , 'notempty')) { $error = true; } //if (zend_validate::is(trim($post['hideit']), 'notempty')) { // $error = true; //} mage::log($error); mage::log($postobject); if ($error) { throw new exception(); } $mailtemplate = mage::getmodel('core/email_template'); /* @var $mailtemplate mage_core_model_email_template */ $mailtemplate->setdesignconfig(array('area' => 'frontend')) ->setreplyto($post['email']) ->sendtransactional( mage::getstoreconfig(self::xml_path_email_template), mage::getstoreconfig(self::xml_path_email_sender), mage::getstoreconfig(self::xml_path_email_recipient), null, array('data' => $postobject) ); if (!$mailtemplate->getsentsuccess()) { throw new exception(); } $translate->settranslateinline(true); mage::getsingleton('customer/session')->addsuccess(mage::helper('contacts')->__('your inquiry submitted , responded possible. thank contacting us.')); $this->_redirect(''); return; } catch (exception $e) { $translate->settranslateinline(true); mage::getsingleton('customer/session')->adderror(mage::helper('contacts')->__('unable submit request. please, try again later')); $this->_redirect('*/*/'); return; } } else { $this->_redirect('*/*/'); } } when log producturl attribute, prints correct view.but not value in email. how value binded gets send email?
my form looks this:
<form action="<?php echo $this->geturl('contacts/index/post'); ?>" id="contactform" method="post"> <div class="row"> <div class="col-sm-12"> <!--<label for="name" class="required"><em>*</em><?php echo mage::helper('contacts')->__('name') ?></label>--> <div class="input-box"> <input name="name" id="name" placeholder="name*" title="<em>*</em><?php echo mage::helper('contacts')->__('name') ?>" value="<?php echo $this->escapehtml($this->helper('contacts')->getusername()) ?>" class="input-text required-entry" type="text" /> </div> </div> <div class="col-sm-12"> <!--<label for="email" class="required"><em>*</em><?php echo mage::helper('contacts')->__('email') ?></label>--> <div class="input-box"> <input name="email" id="email" placeholder="email*" title="<?php echo mage::helper('contacts')->__('email') ?>" value="<?php echo $this->escapehtml($this->helper('contacts')->getuseremail()) ?>" class="input-text required-entry validate-email" type="text" /> </div> </div> <div class="col-sm-12"> <!--<label for="telephone" class="required"><em>*</em><?php echo mage::helper('contacts')->__('mobile') ?></label>--> <div class="input-box"> <input name="telephone" id="telephone" placeholder="mobile*" title="<?php echo mage::helper('contacts')->__('telephone') ?>" value="" class="input-text required-entry" type="text" /> </div> </div> <div class="col-sm-12"> <div class="input-box"> <input name="producturl" id="producturl" placeholder="product url*" title="<?php echo mage::helper('contacts')->__('producturl') ?>" value="url hai bhai" class="input-text required-entry" type="text" /> </div> </div> </div> <div class="row"> <div class="col-sm-12"> <!--<label for="comment" class=""><?php echo mage::helper('contacts')->__('comment') ?></label>--> <div class="input-box input-textarea"> <textarea name="comment" id="comment" rows="3" placeholder="message" title="<?php echo mage::helper('contacts')->__('comment') ?>" class=" input-text" placeholder="<?php echo mage::helper('contacts')->__('comment') ?>" style="width: 100%; height: 15%;resize:none;"></textarea> </div> </div> </div> <div class="row" style="text-align: center"> <div class="col-sm-12" style="padding-top:2%"> <input type="text" name="hideit" id="hideit" value="url hai bhai" style="display:none !important;" /> <button type="submit" title="<?php echo mage::helper('contacts')->__('submit') ?>" class="button"><span><span><?php echo mage::helper('contacts')->__('book designer') ?></span></span></button> </div> </div> </div> </div>
so, emails templates html files can find in folder app/locale/[some_locale]/template/ if locale english of some_locale en_us, if french belgium, fr_be, language code on 2 letter defined iso 639-1 underscore _ , country code defined iso 3166-1 alpha-2.
and name of file find if global search on handle of template stated in comment.
so here contacts_email_email_template defined in app/code/core/mage/contacts/etc/config.xml being file contact_form.html :
<template> <email> <contacts_email_email_template translate="label" module="contacts"> <label>contact form</label> <file>contact_form.html</file> <type>text</type> </contacts_email_email_template> </email> </template> so if go , edit app/locale/en_us/template/email/contact_form.html reproduced here bellow , in added product url value, should work :
<!--@subject contact form@--> <!--@vars {"var data.name":"sender name", "var data.email":"sender email", "var data.telephone":"sender telephone", "var data.comment":"comment"} @--> name: {{var data.name}} email: {{var data.email}} telephone: {{var data.telephone}} comment: {{var data.comment}} <!-- bellow line after --> product url : {{var data.producturl}} data, being key of array passing fifth argument of function sendtransactional
Comments
Post a Comment