Jump to content

Add php (require_once) to top of cms page?


flamedtofu

Recommended Posts

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

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

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

  • Like 1
Link to comment
Share on other sites

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

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';
	
  • Like 1
Link to comment
Share on other sites

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

:)

 

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

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
×
×
  • Create New...