Jump to content

How to create a Copy of Contact Form?


Recommended Posts

Hello everyone!

 

I'd like to create another one contact form within prestashop (in addition to existing one).

I tried to copy contact-form.php and changed code to request copied Controller (controllers/ContactController) and a class (classes/Contact.php) with tpl file but all i see is an "error 500" result. (Maybe some database fields required?)

 

I hope someone tried and managed to find a solution.

 

Thanks in advance.

 

-------

Prestashop 1.4.3

Motul-oil.com.ua

Link to comment
Share on other sites

1 .It is better that you copy a set of all three files.

 

contact-form.php

controllers/ContactController.php

themes/YourSiteTheme/contact-form.tpl

 

2. Rename all of the files to new ones

 

contact-formXXX.php

controllers/ContactXXXController.php

themes/YourSiteTheme/contact-formXXX.tpl

 

3. Change related places in

controllers/ContactXXXController.php

 

 

class ContactXXXControllerCore extends FrontController
{
public function __construct()
{
	$this->php_self = 'contact-formXXX.php';
	$this->ssl = true;

	parent::__construct();
}


....


public function displayContent()
{
	$_POST = array_merge($_POST, $_GET);
	parent::displayContent();
	self::$smarty->display(_PS_THEME_DIR_.'contact-formXXX.tpl');
}
}

 

please note above XXX needs to be changed to your own names

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

1 .It is better that you copy a set of all three files.

 

contact-form.php

controllers/ContactController.php

themes/YourSiteTheme/contact-form.tpl

 

2. Rename all of the files to new ones

 

contact-formXXX.php

controllers/ContactXXXController.php

themes/YourSiteTheme/contact-formXXX.tpl

 

3. Change related places in

controllers/ContactXXXController.php

 

 

class ContactXXXControllerCore extends FrontController
{
public function __construct()
{
	$this->php_self = 'contact-formXXX.php';
	$this->ssl = true;

	parent::__construct();
}


....


public function displayContent()
{
	$_POST = array_merge($_POST, $_GET);
	parent::displayContent();
	self::$smarty->display(_PS_THEME_DIR_.'contact-formXXX.tpl');
}
}

 

please note above XXX needs to be changed to your own names

 

I'm using v1.4.4.1 and I followed the instructions, and I get Warning & Fatal Errors (I used XXXXX in-lieu-of names):

 

Warning: require(/home/XXXXX/public_html/XXXXX../config/config.inc.php) [function.require]: failed to open stream: No such file or directory in /home/XXXXX/public_html/XXXXX/contact-map.php on line 28

 

Fatal error: require() [function.require]: Failed opening required '/home/XXXXX/public_html/XXXXX../config/config.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/XXXXX/public_html/XXXXX/contact-map.php on line 28

 

What other files require replacing/adjusting?

Do I create another config.inc.php and label it config.XXX.php ?

Link to comment
Share on other sites

  • 4 weeks later...

Hi Everyone!

 

I made everything explained above but nothing happened... On BO Preference/SEO&URL I've add the page contact-formXXX.php with personalize link. When I try to go on browser www.xxx.com/contact-formXXX.php I land on initial contact page.

 

Don't know what to do. Please help

Link to comment
Share on other sites

  • 5 months later...

Thanks for the code above. I am trying it and it seems to be going fine till now.

What i couldn't get is that how to set the email template for this new contact form.

 

 

what i got to learn from some other posts is that following files are used in default contact form email template

/mails/en(or and other languages using)/contact.html

/mails/en(or and other languages using)/contact.txt

/mails/en(or and other languages using)/contact_form.html

/mails/en(or and other languages using)/contact_form.txt

 

So my point is if i create a new file here for my custom contact form , where should i specify in my controller (or wherever it is needed to be mentioned) to use that particular file.

  • Like 1
Link to comment
Share on other sites

The only lines mentionning these emails name in XXXControllerCore are :

 

L156+157

 

if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from))

 

AND L206

 

Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);

 

So I guess you can duplicate and rename contact.html and contact_form.html and then change the code accordingly.

 

But I'm still stuck in the previous step. Can you tell me how you changed the code in XXXControllerCore.

I am able to display my new form but it is not working AND it makes the original form non functionnal.

Can the problem come from public $php_self = 'XXXX.php'; ?

 

class XXXXControllerCore extends FrontController
{
public $php_self = 'XXXX.php';
public $ssl = true;
public function preProcess()
{
 parent::preProcess();

Edited by Whirly (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

1 .It is better that you copy a set of all three files.

 

contact-form.php

controllers/ContactController.php

themes/YourSiteTheme/contact-form.tpl

 

2. Rename all of the files to new ones

 

contact-formXXX.php

controllers/ContactXXXController.php

themes/YourSiteTheme/contact-formXXX.tpl

 

3. Change related places in

controllers/ContactXXXController.php

 

 

class ContactXXXControllerCore extends FrontController
{
public function __construct()
{
	$this->php_self = 'contact-formXXX.php';
	$this->ssl = true;

	parent::__construct();
}


....


public function displayContent()
{
	$_POST = array_merge($_POST, $_GET);
	parent::displayContent();
	self::$smarty->display(_PS_THEME_DIR_.'contact-formXXX.tpl');
}
}

 

please note above XXX needs to be changed to your own names

 

Hi

i just follow all the steps and i named employee instead of contact and now its showing me one another page named employee but i want to add contact-form.css on my page its not displaying that css for my employee page can you plz help me

Link to comment
Share on other sites

×
×
  • Create New...