Jump to content

How to Create a Second-Level Custom Page?


amos-n-andy

Recommended Posts

Hi all !

 

It is really easy to set up a new custom page in Prestashop.

 

I’ll briefly reproduce this method for clarity:

  1. Create initial page in your prestashop root folder  (e.g.  your-page-name.php). Fill it with this code: 
    <?php
    
    require(dirname(__FILE__).'/config/config.inc.php');
    
    Tools::redirect('index.php?controller=your-page-name'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
  2. Create controller in controllers/front/YourPageNameController.php. Fill in this code: 
    <?php
    
    class YourPageNameControllerCore extends FrontController
    {
    
      public $php_self = ' your-page-name ';
    
      public function setMedia()
      {
    		parent::setMedia();
    
    		$this->context->controller->addCSS(_THEME_CSS_DIR_.' your-page-name.css', 'all');
      }
    
      public function displayContent()
      {
    	parent::displayContent();
    	self::$smarty->display(_PS_THEME_DIR_.' your-page-name.tpl');
      }
    
    }
  3. Create view in themes/yourTheme/ your-page-name.tpl.

 

And voilà we have a new custom page which can be accessed like your-domain.fr/your-page-name

 

But the question is how to create a “second-level” link for another subsidiary custom page like: your-domain.fr/your-page-name/another-custom-page ?

 

P.S. I don’t really want to use Apache mod_rewrite for this purpose. Maybe this can be done with plain PHP methods? Like in Zend Framework where you can create actions for controller classes to achieve this link structure: your-domain.fr/controller-name/action-name/parameter1/value1/.../parameterN/valueN

Link to comment
Share on other sites

HI

 

in you tpl of 1st page in the link for 2nd page

<a href="{$link->getPageLink('your2nd_page_on_root_of_ps.php')}">{l s='your2nd_page_on_root_of_ps'}</a>

and like the the1st page  "your2nd_page_on_root_of_ps.php" call the controller and controler call tpl in the theme

 

@++

 

Loulou66

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