Jump to content

Multiple Contact Forms (One for general contact then another on a CMS page for Trade REQ)


evolution.x
 Share

Recommended Posts

Hi,

Does anyone know if prestashop is able to use two separate contact forms, for example i need the general contact form located at contact-form.php then i need another one on maybe a CMS page for a trade application??

I think it may be possible to use the current contact form but duplicate it and call all relevant files/hooks/calls contact-form2 for example. It needs to have all the same functions and maybe a dedicated back office page.

Basically i need contact-form.php and contact-form2.php which work completely separate to each other.

Any help off you guys on this matter would be greatly appreciated!!!

Thanks in advance.

Adam

Share this post


Link to post
Share on other sites

Yes, you just need to duplicate the contact-form.php that is in the root folder and the contact-form.tpl in the theme, change the names of the files to match each other. At the bottom of the php file, you need to change the file that is called to the tpl you renamed.

  • Like 1

Share this post


Link to post
Share on other sites

  • 3 weeks later...
Yes, you just need to duplicate the contact-form.php that is in the root folder and the contact-form.tpl in the theme, change the names of the files to match each other. At the bottom of the php file, you need to change the file that is called to the tpl you renamed.


excellent. This seems to work but I'm wondering how I might go about embedding a form into a CMS page. I want the client to be able to add content to the page via the backend CMS feature but I want the contact form to be hard-coded below that content so they can't screw things up with it. Right now I'm using:
{if $smarty.get.id_cms == '13'} 

to control content on specific pages (not sure if that's the best technique or not but works well). So I'd like to embed another contact form into the tpl file that only appears on certain pages. I tried copying from and hacking up the code from contact-form.tpl and adding to my cms.tpl file but I can't get it to work. I've also had a ton of problems using generic (non-presta) contact forms within the cms.tpl file.

Any help would be greatly appreciated.

thanks, Shag

Share this post


Link to post
Share on other sites

excellent. This seems to work but I'm wondering how I might go about embedding a form into a CMS page. I want the client to be able to add content to the page via the backend CMS feature but I want the contact form to be hard-coded below that content so they can't screw things up with it. Right now I'm using:
{if $smarty.get.id_cms == '13'} 

to control content on specific pages (not sure if that's the best technique or not but works well). So I'd like to embed another contact form into the tpl file that only appears on certain pages. I tried copying from and hacking up the code from contact-form.tpl and adding to my cms.tpl file but I can't get it to work. I've also had a ton of problems using generic (non-presta) contact forms within the cms.tpl file.



Never mind. I hadn't "hacked" hard enough. I was able to embed a contact form on certain CMS pages using the conditional logic described above and using the code below which utilizes the standard contact-form.php out of the box. I just hard-coded some of the values in the form. Only catch is that after the form is submitted, the user gets redirected to the contact-form.php page. I'm sure that's fixed easily enough but I can live with it for now. Here's the (completely hacked and probably not the best way to do it) code I used in my cms.tpl file...

(note the hard-coded form action and hidden "id_contact" field to control who the form submits to)

>
{if isset($confirmation)}

{l s='Your message has been successfully sent to our team.'}
</pre>
<ul>
{l s='Home'}
</ul>
<br>{else}<br><p>{l s='For questions about an order or for information about our products'}.</p>
<br><br>   {include file=$tpl_dir./errors.tpl}<br>   <form action="/dev/contact-form.php" method="post" class="std"><br>   <input type="hidden" name="id_contact" value="2" /><br><br><p>
{l s='E-mail address :'}
           <input type="text" id="email" name="from" value="{$email}" />
</p>
<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><p>
           <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button" />
</p>
<br><br></form><br>{/if

Share this post


Link to post
Share on other sites

  • 5 years later...
  • 11 months later...

For 1.6 do the following:

 

  1. Duplicate ContactController.php and rename to ex. NewContactController
  2. Change class name from ContactControllerCore to ex. NewContactControllerCore
  3. Change the php self variable to ex. newcontact on line 29
  4. Duplicate contact-form.tpl and rename to ex. new-contact-form.tpl
  5. Point to your new template file by editing $this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl'); on line 255
  6. Delete class_index.php in cache folder in root directory
  7. Login to admin backend and add page to SEO & URLS.
  8. Access the page URL by http://example.com/i...ller=newcontact

 

This is how i got a second contact page to display. Adding new form fields and variables is up to you.

 

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More