Jump to content

Front-end controller overrides not working for PS 1.7.0.5


tinman47

Recommended Posts

Front-end controller overrides that worked for 1.6 don't translate over to 1.7 - Here is my about page controller code located in root/controllers/front

 

It keeps returning a "No Template found error", but its in the directory

 

AboutPageController.php:

<?php

  /*  The classname here will be the name of the controller  */
  class AboutPageController extends FrontController {
 
    public function init(){
      parent::init();
    }
     
    public function initContent(){
      parent::initContent();
      $this->setTemplate(dirname(__FILE__).'/templates/about.tpl');
    }
 
  /*  The following code portion is optional.
   *  Remove the double-slashes to activate the portion
   *  if you want to use external stylesheet and JavaScript for the page.
   *  Create the CSS and JS files in the css and js directories of the theme accordingly
   */
   
  public function setMedia(){
      //parent::setMedia();
      //$this->addCSS(_THEME_CSS_DIR_.'custom-page.css');
      //$this->addJS(_THEME_JS_DIR_.'custom-page.js');

    parent::setMedia();
    $this->addCSS('custom_pages/custom-styles.css');
    $this->addJS('custom_pages/custom-script.js');
  }
    
}
Link to comment
Share on other sites

AboutPageController is not available on the prestashop 1.7.x.x version.

 

AboutPageController is not available in ANY Prestashop version.  This must be a custom controller that you created, in which case you should not be using an override.  You should create a module that has a controller.

Link to comment
Share on other sites

Figured it out. Its a little more involved than I thought.  Here's the solution in case anyone is trying to figure it out:

 

Create AboutPageController.php and place inside root/controllers/front/ (You can place into a folder in this directory if you like).Here is the code for AboutPageController.php:

<?php

  /*  The classname here will be the name of the controller  */
  class AboutPageController extends FrontController {
 
    public function init(){
      parent::init();
    }
     
    public function initContent(){
      parent::initContent();
      $this->setTemplate('about');
    }
    
}

Now go into your theme, and add the .tpl file into root/themes/current_theme/templates - In this case I'm adding about.tpl:

{extends file='page.tpl'}

{block name='page_header_container'}{/block}

{block name='page_content'}

{* Page content *}

{/block}

All HTML and page content goes into the block named "page_content". Now with that completed, go into your backend for Prestashop, go into "Traffic & SEO" and  add a new page, then find your page and set whatever the rewrite is.

 

And the final step (there are so many steps), is to go into app/cache/dev (or prod depending on what your environment is set to) -  and delete the file class_index.php - That should be it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...