flamedtofu Posted November 10, 2013 Share Posted November 10, 2013 Hey all, I am trying to intergrate "simple contact form pro" into a single cms page on prestashop, I have "simplecontactform pro" setup successfully on the same server as my prestashop install and it is working, The bit I am struggling with is integrating it into my cms page, Acording to their documenation here, http://www.simplecontactform.com/pro/docs/installation.php I need to add the following to the top of the php page where I will place this form require_once 'sc-admin/include/common.php'; require_once 'sc-admin/include/contact.php'; Now I can't workout for the life of me how to do this, a few posts I have read have suggested I add it into cmscontroller.php which didn't work, perhaps I need to create a custom hook? I am a bit of a n00b when it comes to php, I can do a little copying and pasting but i'm no expert, any point in the right direction would be amazing. cheers Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted November 10, 2013 Share Posted November 10, 2013 Hi, what version do you use? I suggest you override CmsController and change init function with your code. Also check your lines with file_exists. Regards Link to comment Share on other sites More sharing options...
flamedtofu Posted November 10, 2013 Author Share Posted November 10, 2013 Prestashop version 1.5.4 Thanks for the tip alexander, do you know if there are Abby guides on adding this? I did try adding it to here but didn't really know what i was doing and just ebbed up with a black page on all the cms pages. There isn't really much code to add, only the two require once commands to load the required php files for the form to work. Link to comment Share on other sites More sharing options...
vekia Posted November 10, 2013 Share Posted November 10, 2013 hello you need to paste this code to the init function, can you show us what you did (how your code looks like?) remember to turn on error reporting, then instead of blank page you will see full error code - things will be easy to debug then 1 Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted November 10, 2013 Share Posted November 10, 2013 Vekia is absolutely right, blank screen is the indicates about error in your code, read more: http://blog.belvg.com/showing-php-and-sql-errors-and-debugging-a-blank-white-page-in-prestashop.html Link to comment Share on other sites More sharing options...
flamedtofu Posted November 10, 2013 Author Share Posted November 10, 2013 The error I get is the following, Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting ';' or '{' in /var/www/html/controllers/front/CmsController.php on line 47 /** * Initialize cms controller * @see FrontController::init() */ public function init() require_once 'sc-admin/include/common.php'; require_once 'sc-admin/include/contact.php'; { parent::init(); if ($id_cms = (int)Tools::getValue('id_cms')) $this->cms = new CMS($id_cms, $this->context->language->id); else if ($id_cms_category = (int)Tools::getValue('id_cms_category')) $this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id); $this->canonicalRedirection(); // assignCase (1 = CMS page, 2 = CMS category) if (Validate::isLoadedObject($this->cms)) I wasn't sure how I put it in the "init function" all I could find in controllers/front/cmscontrollers.php that resembled it was "public function init()" and then all I did was copy and pasted the two required files under here which I didn't think was right. Cheers , I appreciate the assistance. Link to comment Share on other sites More sharing options...
vekia Posted November 10, 2013 Share Posted November 10, 2013 take a look on your code: public function init(){ require_once 'sc-admin/include/common.php'; require_once 'sc-admin/include/contact.php'; require_once codes are outside the brackets, code you pasted must be inside function: public function init(){ require_once 'sc-admin/include/common.php'; require_once 'sc-admin/include/contact.php'; 1 Link to comment Share on other sites More sharing options...
flamedtofu Posted November 11, 2013 Author Share Posted November 11, 2013 Thanks Vekia, that worked, the form is now displaying on my cms page Looks like for it to work there is still a little more code to add. Do you know where I should add this javascript? <script language="JavaScript" type="text/javascript" charset="utf-8" src="sc-admin/libraries/jquery/jquery.js"></script> <script language="JavaScript" type="text/javascript" charset="utf-8" src="sc-admin/js/common.js"></script> <script language="JavaScript" type="text/javascript" charset="utf-8" src="sc-admin/js/forms.js"></script> Link to comment Share on other sites More sharing options...
vekia Posted November 11, 2013 Share Posted November 11, 2013 in <header></header> section in your header.tpl file Link to comment Share on other sites More sharing options...
flamedtofu Posted November 11, 2013 Author Share Posted November 11, 2013 Is there a way I can find out the non friendly url of a cms page? ie the generated .php file name, looks like to get this form to work i need to have the file name in the action feild: <form id="form_contact" action="contact.php" method="post" name="form_contact" accept-charset="UTF-8"> Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted November 11, 2013 Share Posted November 11, 2013 You can get url for specific page with function Context::getContext()->link->getPageLink('contact') Link to comment Share on other sites More sharing options...
flamedtofu Posted November 11, 2013 Author Share Posted November 11, 2013 Thanks Alexander, Can I be a n00b and ask how I run that function? also i'm not sure if this will solve it or not, as a quick google has brought up I should be able to set action to "" on forms to use the current page, doing this doesn't work Link to comment Share on other sites More sharing options...
vekia Posted November 11, 2013 Share Posted November 11, 2013 i think that if you use: {Context::getContext()->link->getPageLink('contact')} instead of simple "contact.php" you will achieve what you expect Link to comment Share on other sites More sharing options...
flamedtofu Posted November 11, 2013 Author Share Posted November 11, 2013 Still no luck thanks for all of your help though, I'm starting to get desperate to get this fixed (have a competition going live in a magazine tomorrow, that requires this form), I've put a job up on Elance if anyone is interested: https://www.elance.com/job/49139620/proposals Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now