Custom page in Prestashop 1.6 without CMS

吃可爱长大的小学妹 提交于 2019-12-06 04:45:02

问题


I'm currently creating a customized page based on Bootstrap so I cannot pass through the CMS.

I created a file Mypage.php that I put at the Prestahop root 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');
    }
}

And finally I put a Mypage.tpl file in my theme directory with my HTML code.

I naturally erased cache/class_index.php but I still get a 404 error. Any ideas?


回答1:


  • 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 for the Page field.

There is no need for the Mypage.php in your root, you can access your controller at link yoururl/index.php?controller=mypage. But if you want to use it, write Controller::getController('MypageController')->run();.




回答2:


Not sure your code cause I did not test it but you should go to SEO & URLs create new page and choose your new page Mypage, title of the page, friendly urls meta tag and keywords.




回答3:


You can create a new module for you custom page.

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



来源:https://stackoverflow.com/questions/27385742/custom-page-in-prestashop-1-6-without-cms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!