Create custom page in Prestashop 1.5.3

后端 未结 4 600
无人共我
无人共我 2020-12-05 15:47

I\'d like to create a custom page in Prestashop 1.5.3 without using CMS.

Unfortunately I can not find any tutorials that are working with 1.5.3.

So far I hav

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 16:33

    Just create a controller with the name you want for the page, and put it in /overrides/controllers/front/. The name of the controller must be NameyouwantforthepageController.php

    Here is a basic class that will work:

    class MyPageController extends FrontController {
    
    /**
     *  Initialize controller
     *  @see FrontController::init()
     */
    public function init() {
        parent::init();
    }
    
    /**
     *  Assign template vars related to page content
     *  @see FrontController::initContent()
     */
    public function initContent() {
        parent::initContent();
    
        $this->setTemplate(_PS_THEME_DIR_.'my-page.tpl');
    }
    
    }
    

    Take a look at the FrontController to see what method you need to override to add functionnalities, for example setMedia() to add CSS / JS files.

    You will then be able to add a pretty url in the back office in the SEO panel.

提交回复
热议问题