Jump to content

Adding contact information in contact form


Recommended Posts

  • 1 month later...
  • 1 month later...

Hello,

 

This has already been covered into other posts in this forum, I suggest you have a search.

 

In essence, if you would like to save the new field you are adding in your contact-form.tpl is to update, if I am not mistaken so please check, the Contact.php class (in classes directory). This class inherits from ObjectModel and defines the structure of the <PRESTADBPREFIX>_contact table. Obviously, you would have to add the new field in the database table structure and then update Contact.php to add this extra field (in the same fashion at the other fields already there in the table with correct type and sizing).

 

Alternatively, I do not recommend to change core PrestaShop core files as the changes you make now will be erased as soon you upgrade version. I suggest you create a module which would actually replace the core contact block. Additional information and documentation can be found here: http://doc.prestashop.com/display/PS15/Fundamentals

 

BR,

RaPhiuS

  • Like 1
Link to comment
Share on other sites

Nice, RaPhiuS. Thanks for your advice!

 

I'm building a new module to add fields to the contact form but I can't find the way to "override" the contact-form.tpl (I mean, add the input fields without modifying the core template file)

 

Regards

Link to comment
Share on other sites

Well, I guess the best way to achieve it is overriding the Contact controller in the module, then write a customized "initContent" method and use the "setTemplate" method to point a new template. Something like this:

 

public function initContent()

{

parent::initContent();

$this->setTemplate('my-contact-form.tpl');

}

 

Could any experienced prestashop developer confirm it, please?

 

Regards

Link to comment
Share on other sites

By essence, if you override the Contact controller, and by that I mean using inheritance, then obviously the method initContent() from your "class inheriting from Contact controller" will be called at the very last in the stack tree, therefore setTemplate() will override, hence this confirm your question.

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...