Jump to content

Best Way to Add Custom Pages?


Recommended Posts

When i was using 1.3x, I would just create a .php page like the other pages with the:

 

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

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

 

etc...

 

I see now controllers are used now:

 

require(dirname(__FILE__).'/config/config.inc.php');

ControllerFactory::getController('SitemapController')->run();

 

What is the best way to create my own .PHP pages?

Link to comment
Share on other sites

  • 3 weeks later...

The below method is a bit hackish, but it seems to work. Put the following code in to a custom .php file on your root folder.

 

<?php

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

// create a new class and make the canonicalRedirection method blank

ControllerFactory::includeController('IndexController');

class CustomController extends IndexController {

public function canonicalRedirection () {

}

}

 

$controller = new CustomController();

 

$controller->init();

$controller->displayHeader();

 

/*

* custom code here

*/

// add content using templates

$smarty->display(_PS_THEME_DIR_.'custom-page.tpl');

 

$controller->displayFooter();

 

?>

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...