Jump to content

Anyone knows his/her way around Prestashop contact forms?


keith13908

Recommended Posts

Hi there,

 

I'm making a website in Prestashop and I'm trying to personalize my contact form. The makers of the theme says

to modify the contact-form.tpl file. So far I've managed to rewrite the texts but still don't know how to modify

the drop down box and choose the email where the message is sent.  :-\

 

Would you guys know how to solve this? For some reason I believe it isn't difficult, just have to find which part of

the code to modify. I'll attach an image for it. Any help would be very much appreciated.  :)

 

Keith

post-133213-13482403434931_thumb.jpg

There seems to be two contact-form.tpl files. There is also one contact-form.php file. What do you guys think?  :shrug:

 

 

TPL File 1

{capture name=path}{l s='Contact'}{/capture}

{include file=$tpl_dir./breadcrumb.tpl}

<h2>{l s='Contact us'}</h2>

<div id="contact_us">

 

{if isset($confirmation)}

<p>{l s='Your message has been successfully sent to our team.'}</p>

<ul class="footer_links">

<li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>

</ul>

{else}

<p class="contact_text">{l s='For questions about an order or for information about our products'}.</p>

{include file=$tpl_dir./errors.tpl}

<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std">

<fieldset>

<p class="select">

<label for="id_contact">{l s='Subject :'}</label>

<select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">

<option value="0">{l s='-- Choose --'}</option>

{foreach from=$contacts item=contact}

<option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>

{/foreach}

</select>

</p>

{foreach from=$contacts item=contact}

<p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">

<label> </label>{$contact.description|escape:'htmlall':'UTF-8'}</p>

{/foreach}

<p>

<label for="email">{l s='E-mail address :'}</label>

<input type="text" id="email" name="from" value="{$email}" />

</p>

<p class="textarea">

<label for="message">{l s='Message :'}</label>

<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>

<p class="submit">

<input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button" />

</p>

</fieldset>

</form>

{/if}

</div>

 

 

TPL File 2

{capture name=path}{l s='Contact'}{/capture}

{include file=$tpl_dir./breadcrumb.tpl}

 

<h2>{l s='Contact us'}</h2>

 

{if isset($confirmation)}

<p>{l s='Your message has been successfully sent to our team.'}</p>

<ul class="footer_links">

<li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>

</ul>

{else}

<p class="bold">{l s='For questions about an order or for information about our products'}.</p>

{include file=$tpl_dir./errors.tpl}

<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std">

<fieldset>

<h3>{l s='Send a message'}</h3>

<p class="select">

<label for="id_contact">{l s='Subject'}</label>

<select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">

<option value="0">{l s='-- Choose --'}</option>

{foreach from=$contacts item=contact}

<option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>

{/foreach}

</select>

</p>

<p id="desc_contact0" class="desc_contact"> </p>

{foreach from=$contacts item=contact}

<p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">

<label> </label>{$contact.description|escape:'htmlall':'UTF-8'}</p>

{/foreach}

<p class="text">

<label for="email">{l s='E-mail address'}</label>

<input type="text" id="email" name="from" value="{$email}" />

</p>

<p class="textarea">

<label for="message">{l s='Message'}</label>

<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>

<p class="submit">

<input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" onclick="$(this).hide();" />

</p>

</fieldset>

</form>

{/if}

 

 

PHP File

<?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 (!($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 contact in the list');

    else

    {

if (intval($cookie->id_customer))

$customer = new Customer(intval($cookie->id_customer));

if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))

$smarty->assign('confirmation', 1);

else

$errors[] = Tools::displayError('an error occurred while sending message');

    }

}

 

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : '')));

$smarty->assign(array(

'errors' => $errors,

'email' => $email

));

 

$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');

include(dirname(__FILE__).'/footer.php');

 

?>

  • 2 weeks later...

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

 

Is the line in the php file that gets the contacts you can select from (which is the subject drop down). If it's not in the config file as PFM suggests, it's probably in a table in your DB.

  • 8 months later...

...

So far I've managed to rewrite the texts but still don't know how to modify

the drop down box and choose the email where the message is sent. :-\

...

...

If it's not in the config file as PFM suggests, it's probably in a table in your DB.

 

This thread seems a little old, but had the same problem and though I should share the answer that worked for me:

 

The mail where it's sent can be configured in the backend (at least in prestashop 1.5). You can find it in "Customer"->"Contact"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.