Custom page in Prestashop 1.6 without CMS
I am currently creating a custom page based on Bootstrap so I cannot go through the CMS.
I created a file Mypage.php
that I installed in the root of Prestahop containing this code:
<?php
require(dirname(__FILE__).'/config/config.inc.php');
ControllerFactory::getController('MypageController')->run();
?>
Then I created a controller MypageController.php
containing this code in override / controllers / front:
class MypageControllerCore extends FrontController
{
public $php_self = 'Mypage.php';
public $ssl = true;
public function preProcess()
{
parent::preProcess();
}
public function setMedia()
{
parent::setMedia();
Tools::addCSS(_THEME_CSS_DIR_.'Mypage.css');
}
public function displayContent()
{
$_POST = array_merge($_POST, $_GET);
parent::displayContent();
self::$smarty->display(_PS_THEME_DIR_.'Mypage.tpl');
}
}
Finally, I put the file Mypage.tpl
in the theme directory with my HTML code.
I erase naturally, cache/class_index.php
but I still get 404 error. Any ideas?
source to share
- Move
MypageController.php
toroot/controllers/front
. - Change
public $php_self = 'mypage';
. - Go to
BO > Preferences > SEO & URLs
and add a new page, selectmypage
"Page" for the field.
No need for Mypage.php
your root, you can access your controller from the link yoururl/index.php?controller=mypage
. But if you want to use it, write Controller::getController('MypageController')->run();
.
source to share
You can create a new module for your custom page.
http://doc.prestashop.com/display/PS16/Creating+a+first+module
source to share