Jump to content

adding some extra php code to custom pages (Solved)


mr WB

Recommended Posts

Hello everyone,
 

 

I have a question about adding some extra PHP content to custom pages that are created using this tutorial.

Creating the custom pages works. However on a couple of the pages I have to add a custom created slider.

I know the slider works because I have created a text index file in my folder to check if everything works.

 

I know editing the tpl files so they use can use php code is a bad idea for security reasons.  

I need to add some code elements so the slider will appear above the tpl content.

I have a basic knowledge of php coding and have tried adding it to the page using the include"path/myPage.php"; with a myFunction();  method. However using the basic php include will not work. (white screen even with a simple echo in the included file).

 

one of my custom pages looks like this:

<?php
  /*  Create a custom page in PrestaShop without CMS - CustomPageController class
  /*  Read the detailed tutorial at https://iftakharhasan.wordpress.com/prestashop-create-a-custom-page-without-cms
   */
 
  /*  The classname here will be the name of the controller  */
  class MontageServiceController extends FrontController
  {
 
    public $php_self = 'montage-service';

    public function init()
	{
      parent::init();
    }
     
    public function initContent()
	{
      parent::initContent();
		
		// ADD SLIDER HERE?
		
		$this->setTemplate(_PS_THEME_DIR_.'custom/montage-service.tpl');

    }

  /*  The following code portion is optional.
  /*  Remove the double-slashes to activate the portion
  /*  if you want to use external stylesheet and JavaScript for the page.
  /*  Create the CSS and JS files in the css and js directories of the theme accordingly
   */
   
    //public function setMedia(){
      //parent::setMedia();
      //$this->addCSS(_THEME_CSS_DIR_.'custom-page.css');
      //$this->addJS(_THEME_JS_DIR_.'custom-page.js');
    //}
    
}

the content i need to add to make it work is:

//include config file
    include"myURL/custom-slider/application/config/config.php";
   
// include slider system
    include"myURL/custom-slider/application/modules/slider.php";

//include slider content
    include"myURL/custom-slider/assets/images/slider1/slidercontent.php";

// run the slider the slider
    $nivo->render_includes();
    $nivo->render_slides();
       

I only need to add this to a couple of custom pages not all of them.

Any idea where i should look or what i'm doing wrong?

EDIT: Fixed the problem with the module sliders everywhere :)

 

 

Edited by mr WB (see edit history)
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...