tinman47 Posted February 27, 2017 Share Posted February 27, 2017 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 More sharing options...
bellini13 Posted February 28, 2017 Share Posted February 28, 2017 What is AboutPageController? This does not appear to be a core controller, so why are you trying to override it? 1 Link to comment Share on other sites More sharing options...
Xpert-Idea Posted February 28, 2017 Share Posted February 28, 2017 AboutPageController is not available on the prestashop 1.7.x.x version. but you have to need set template like this : $this->setTemplate('about'); and you have to need create a about.tpl file on your theme templates directory Link to comment Share on other sites More sharing options...
bellini13 Posted February 28, 2017 Share Posted February 28, 2017 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 More sharing options...
tinman47 Posted February 28, 2017 Author Share Posted February 28, 2017 (edited) @Xpert-Idea: $this->setTemplate('about'); Ah so that partially worked. Put the .tpl template into the theme root and "templates" folder and now it works, but it is not loading any styles. Edited February 28, 2017 by tinman47 (see edit history) Link to comment Share on other sites More sharing options...
tinman47 Posted February 28, 2017 Author Share Posted February 28, 2017 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 More sharing options...
bellini13 Posted February 28, 2017 Share Posted February 28, 2017 You shouldn't do it this way, as I mentioned before, you should create a module that has a controller, this way you properly separate your customization from the Core of Prestashop. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now