Jump to content

ModuleFrontController doesn't show header, leftColumn, footer


Recommended Posts

PS Version 1.7.5

In order to show a page in the front office with come content of my custom module, I have followed the tutorial here: https://devdocs.prestashop.com/1.7/modules/creation/displaying-content-in-front-office/ to create a ModuleFrontcontroller like so: 

class mymoduledisplayModuleFrontController extends ModuleFrontController
{
  public function initContent()
  {
    parent::initContent();
    $this->setTemplate('module:mymodule/views/templates/front/display.tpl');
  }
}

the corresponding .tpl file just has a line of "Welcome" in it.

In the tutorial above it says "With just a few lines, the end result is already much better, with the “Welcome” line neatly placed between header, footer and columns!", except that I don't get that to show up. Here is the resulting source of my page:

<!-- begin module:MyModule/views/templates/front/display.tpl -->
<!-- begin [PATH TO WEBROOT REMOVED IN THIS EXAMPLE]/prestashop/modules/MyModule/views/templates/front/display.tpl -->
Welcome to my shop!

<!-- end [PATH TO WEBROOT REMOVED IN THIS EXAMPLE]/prestashop/modules/MyModule/views/templates/front/display.tpl -->
<!-- module:MyModule/views/templates/front/display.tpl -->

Apparently it doesn't even add body tags.

If I add this to my .tpl file, I get a least header and footer, but leftColumn ist not being displayed either:

{extends file='page.tpl'}
{block name="page_content"}
    <p>Welcome to my shop!</p>
{/block}

Can anyone tell me what I am dong wrong? Or if indeed the tutorial is missing some info, what do I need to put into my display.tpl to get all shop columns?

Many thanks for your help!

P.

Edited by philoupin (see edit history)
Link to comment
Share on other sites

  • 2 years later...

If you are working on PS software. You need to start thinking like someone who doesn't care about programming dogma. Additionally, remember that moderators can have two links in the footer and you can have one. In your case you should rename the class you are extending. Why? Because...

My case:

class CompsoulNavFeaturedModuleFrontController extends ModuleFrontController {
  public function initContent() {
      parent::initContent();
      $this->setTemplate('module:compsoulnavfeatured/views/templates/front/ajax.tpl');
  }
}	

The code above doesn't work, throws an error:
 

Quote

Fatal error: Uncaught Error: Class 'compsoulnavfeaturedajaxModuleFrontController' not found in Controller.php on line 246

But this code is already working:
 

class compsoulnavfeaturedajaxModuleFrontController extends ModuleFrontController {
  public function initContent() {
      parent::initContent();
      $this->setTemplate('module:compsoulnavfeatured/views/templates/front/ajax.tpl');
  }
}

 

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...