Jump to content

How to create custom page and set page_name without using CMS


n13design

Recommended Posts

I want to create a custom group of pages in prestashop.  I don't want to use the CMS pages because they limit too much.  I want to basically create a custom one column page.  We are using prestashop 1.6.

 

The problem is that I can't get the page_name variable to work.  I get an empty id and class in the body tag.  What do I need to do to set the name of the page so that the body tag will show the proper id and class? 

 

I created a custom-page.php in the root prestashop folder

<?php
include(dirname(__FILE__).'/config/config.inc.php');

include(dirname(__FILE__).'/header.php');
 
$smarty->display(_PS_THEME_DIR_.'custom-page.tpl');
 
include(dirname(__FILE__).'/footer.php');

I then created CustomPageController.php in the override>controllers>front folder

<?php
class CustomPageController extends FrontController{
    
    public $php_self = 'custom-page'; 
	 
    public function init(){
	parent::init();
    }
 
    public function initContent(){
        parent::initContent();
        $this->setTemplate(_PS_THEME_DIR_.'custom-page.tpl');
    }
}

I then created the template file in the theme folder

<h1>Custom Page</h1>
Link to comment
Share on other sites

  • 3 months later...

 

I want to create a custom group of pages in prestashop.  I don't want to use the CMS pages because they limit too much.  I want to basically create a custom one column page.  We are using prestashop 1.6.

 

The problem is that I can't get the page_name variable to work.  I get an empty id and class in the body tag.  What do I need to do to set the name of the page so that the body tag will show the proper id and class? 

 

I created a custom-page.php in the root prestashop folder

<?php
include(dirname(__FILE__).'/config/config.inc.php');

include(dirname(__FILE__).'/header.php');
 
$smarty->display(_PS_THEME_DIR_.'custom-page.tpl');
 
include(dirname(__FILE__).'/footer.php');

I then created CustomPageController.php in the override>controllers>front folder

<?php
class CustomPageController extends FrontController{
    
    public $php_self = 'custom-page'; 
	 
    public function init(){
	parent::init();
    }
 
    public function initContent(){
        parent::initContent();
        $this->setTemplate(_PS_THEME_DIR_.'custom-page.tpl');
    }
}

I then created the template file in the theme folder

<h1>Custom Page</h1>

 

Hello did you find the solution? I need to create a custom form page. I try the same method but it doesn't work

thank you

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

I suggest looking at the contact-form page as your reference, copying it and changing the names would work.

 

Thank you I manage to create a custom page following this tutorial.

http://iftakharhasan.wordpress.com/2014/04/05/prestashop-how-to-create-a-custom-page-without-cms/?replytocom=10#respond

and to add it under SEO and URLs

 

Now I need to create the form. I have the desing of the form ready but I dont know how to connect it to database. (I have created the table that I need) any idea?

Link to comment
Share on other sites

  • 2 years later...
  • 9 months later...

Hello geys this solution work perfectlly with override also.

1/ in the folder /override create page manufacturer-detail.php and put this code:

 

include(dirname(FILE).'/config/config.inc.php'); Controller::getController('ManufacturerDetailController')->run();

Tools::displayFileAsDeprecated();

include(dirname(FILE).'/header.php');

$smarty->display(_PS_THEME_DIR_.'manufacturer-detail.tpl');

include(dirname(FILE).'/footer.php');

2/ In the folder /override/controllers/front create page manufacturerDetailController.php and put this code:

class ManufacturerDetailController extends FrontController{

/*public $php_self = 'manufacturer-detail';  */  /* optional */

public function init(){ 
    parent::init(); 
} 

public function initContent(){ 
    parent::initContent(); 
    $this->setTemplate(_PS_THEME_DIR_.'manufacturer-detail.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');
//}

}

3/ in the folder /themes/your-default-theme create page manufacturer-detail.php and put this code:

Hello world

4/ You can go to SEO & URLs in your back office and add new url

You can access tou your page http://yourstore.com/index?controller=ManufacturerDetail

OR

http://yourstore.com/urr-you-have-added-from-back-office

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...