Topstitched Posted February 1, 2009 Share Posted February 1, 2009 Hi,I'm having some problems adding fields to my contact us page. I have edited the contact-form.tpl to include the fields Phone number and how you heard about us: {l s='Phone number'} <input type="text" id="phone" name="phone" /> {l s='How did you hear about us?'} <input type="text" id="source" name="source" /> When I recieve the email notification of the enquiry, my new fields are not showing up. They just show the field id. Message from your shop TopstitchedE-mail address: [email protected]Phone: {phone}Where did you hear about us?: {source}Message: Hello Any ideas on how to fix it? Link to comment Share on other sites More sharing options...
DaveGetStock Posted February 2, 2009 Share Posted February 2, 2009 have you edited the .php file as well? Link to comment Share on other sites More sharing options...
Topstitched Posted February 2, 2009 Author Share Posted February 2, 2009 I am not sure what I need to put in the .php file. I don't want these fields to be required and thought the code in the .php was to remind people that the field needs to be filled out before submitting.Do you know what I need to put in? Link to comment Share on other sites More sharing options...
Topstitched Posted February 2, 2009 Author Share Posted February 2, 2009 Update: I found another thread that talks about this problem and tries to offer a solution:http://www.prestashop.com/forums/viewthread/11123/modules/creation_of_new_fields_in_the_contact_formTried it myself and followed instructions to the dot - but did not work.Has anyone else tried to alter the contact us form?I will post my code for the following three items that are relavant:1. contact-form.php (in your prestashop’s root directory)2. contact-form.tpl (in your themes directory)3. contact.html (yourshopfolder/mails/en/ folder {if thats the language you are using}) Link to comment Share on other sites More sharing options...
Topstitched Posted February 2, 2009 Author Share Posted February 2, 2009 Trying to get the following fields:NameE-mail addressPhone number (not a required field)How did you hear about us? (not a required field)Messagecontact-form.php <?php $useSSL = true; include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/header.php'); $errors = array(); $smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang))); if (Tools::isSubmit('submitMessage')) { if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from)) $errors[] = Tools::displayError('Invalid e-mail address'); elseif (!($name = nl2br2(Tools::getValue('name')))) $errors[] = Tools::displayError('Name cannot be blank'); elseif (!($phone = nl2br2(Tools::getValue('phone')))) $errors[] = Tools::displayError('Phone cannot be blank'); elseif (!($source = nl2br2(Tools::getValue('source')))) $errors[] = Tools::displayError('Source cannot be blank'); elseif (!($message = nl2br2(Tools::getValue('message')))) $errors[] = Tools::displayError('Message cannot be blank'); elseif (!Validate::isMessage($message)) $errors[] = Tools::displayError('invalid message'); elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang))))) $errors[] = Tools::displayError('Please select a subject for your message from the list'); else { if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email)) $smarty->assign('confirmation', 1); else $errors[] = Tools::displayError('An error occurred while sending message'); } } $smarty->assign('errors', $errors); $smarty->display(_PS_THEME_DIR_.'contact-form.tpl'); include(dirname(__FILE__).'/footer.php'); ?> Link to comment Share on other sites More sharing options...
Topstitched Posted February 2, 2009 Author Share Posted February 2, 2009 contact-form.tpl >{capture name=path}{l s='Contact'}{/capture} {include file=$tpl_dir./breadcrumb.tpl} {l s='Contact Us'} {if isset($confirmation)} {l s='Your message has been successfully sent.'} </pre> <ul> {l s='Home'} </ul> <br><br>{else}<br><br><p>{l s='Please feel free to contact us with any enquiries that you may have.'}.</p> <br><br> {include file=$tpl_dir./errors.tpl}<br><br> <form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std"><br><br><br><br><h3>{l s='Send a message'}</h3> <br><br><p> {l s='Subject'} {l s='-- Choose --'} {foreach from=$contacts item=contact} {$contact.name|escape:'htmlall':'UTF-8'} {/foreach} </p> <br><br><p>{l s='Select a subject'}</p> <br><br> {foreach from=$contacts item=contact}<br><br><p> {l s='Description'}{$contact.description|escape:'htmlall':'UTF-8'}</p> <br><br> {/foreach}<br><br><p> {l s='Name'} <input type="text" id="name" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name|escape:'htmlall'|stripslashes}{/if}" /> </p> <br><p> {l s='E-mail address'} <input type="text" id="email" name="from" value="{if isset($smarty.post.from)}{$smarty.post.from|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> <br><p> {l s='Phone number'} <input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.from|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> <br><p> {l s='How did you hear about us?'} <input type="text" id="source" name="source" value="{if isset($smarty.post.source)}{$smarty.post.source|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> <br><br><p> {l s='Message'} <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea> </p> <br><br><p> <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" /> </p> <br><br><br><br></form><br><br>{/if}<br><br><br Link to comment Share on other sites More sharing options...
Topstitched Posted February 2, 2009 Author Share Posted February 2, 2009 contact.html > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Message from {shop_name}</title> </head> <body> </pre> <table style="font-family:Verdana, sans-serif;font-size:11px;color:#374953;width:550px;"> Message from your shop {shop_name} E-mail address: {email} Name: {name} Phone: {phone} Where did you hear about us?: {source} Message: {message} {shop_name} </table> <br></body><br></html><br Link to comment Share on other sites More sharing options...
TropischBruin Posted February 3, 2009 Share Posted February 3, 2009 Why did you add al that code? Link to comment Share on other sites More sharing options...
Topstitched Posted February 3, 2009 Author Share Posted February 3, 2009 Maybe someone who has successfully made changes to the contact form may recognise what I am doing wrong. Link to comment Share on other sites More sharing options...
TropischBruin Posted February 3, 2009 Share Posted February 3, 2009 Maybe someone who has successfully made changes to the contact form may recognise what I am doing wrong. You could have asked first because no-one will scan this code for you. Link to comment Share on other sites More sharing options...
Topstitched Posted February 3, 2009 Author Share Posted February 3, 2009 I did ask first - was told to edit the .php which i tried to no avail - even after hours of searching through other threads in the forum.I am not too sure where I am going wrong - someone who is more familiar with the contact forms can easily pinpoint where the error may be - thus the code to scan for people who can and are willing to help. Link to comment Share on other sites More sharing options...
Cronos Posted February 3, 2009 Share Posted February 3, 2009 Hello People,I have successfully added new fields to the contact form.And email returns all the values which the user enters in the form.Please check the following website for a demo.If anyone requests how an email would be sent.. I will create a contact corresponding to that email address, so that they could see how the email arrives.http://www.explorersbase.com/store/contact-form.phpThanks Link to comment Share on other sites More sharing options...
TropischBruin Posted February 3, 2009 Share Posted February 3, 2009 Why not share you code here? Link to comment Share on other sites More sharing options...
Topstitched Posted February 4, 2009 Author Share Posted February 4, 2009 Hi CronosNice work on getting the form working. Any help you can give me would be much appreciated. I need the following fields in my contact form:SubjectNameE-mail addressPhone number (not a required field)How did you hear about us? (not a required field)MessageSubject, Email and Message (the default settings) are currently working fine. Just need to add Name, Phone and How they heard about us. Thank you muchly! Link to comment Share on other sites More sharing options...
Simple1 Posted July 21, 2009 Share Posted July 21, 2009 in your php your code should have the following form,this is a working chunk from my else statement.hopefully you are able to adapt it to yours.everything else you are doing seems to be ok. else { if ( Mail :: Send ( intval ( $cookie -> id_lang ), 'contact' , 'Message from contact form' , array( '{email}' => $_POST[ 'from' ] , '{message}' => stripslashes ( $message ), '{name}' => stripslashes ( $name ), '{suits_required}' => stripslashes ( $suits_required ),'{kneck}' => stripslashes ( $kneck ),'{chest}' => stripslashes ( $chest ),'{sleeve}' => stripslashes ( $sleeve ),'{waist}' => stripslashes ( $waist ),'{leg}' => stripslashes ( $leg ), '{address}' => stripslashes ( $address ), '{city}' => stripslashes ( $city ), '{postalcode}' => stripslashes ( $postalcode ), '{Country}' => stripslashes ( $Country ), '{telephone}' => $_POST[ 'telephone' ] ), $contact -> email )) $smarty -> assign ( 'confirmation' , 1 ); else $errors[] = Tools::displayError('An error occurred while sending message'); } } Link to comment Share on other sites More sharing options...
Recommended Posts