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?

+3


source to share


3 answers


  • Move MypageController.php

    to root/controllers/front

    .
  • Change public $php_self = 'mypage';

    .
  • Go to BO > Preferences > SEO & URLs

    and add a new page, select mypage

    "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();

.

+7


source


Not sure what your code called, I haven't tested it, but you have to go to SEO and URLs to create a new page and select a new Mypage page, page title, meta tags and friendly URL keywords.



-1


source


You can create a new module for your custom page.

http://doc.prestashop.com/display/PS16/Creating+a+first+module

-2


source







All Articles