Jump to content

PrestaShopException: Template not found


JTDVNT

Recommended Posts

Hello there,

 

I am trying to create a custom page to front office. PrestaShop's version is 1.6.

My custom controller looks like this:

<?php

class MyModuleAllProductsModuleFrontController extends ModuleFrontController
{
    public function __construct()
    {
        parent::__construct();
        $this->context = Context::getContext();
    }

    public function init()
    {
        $this->page_name = 'all-products';

        parent::init();
    }

    public function initContent()
    {
        parent::initContent();

        $this->setTemplate(_PS_THEME_DIR_ . 'all-products.tpl');
    }
}

But when I try to access to the page I get the following exception:

 

MJ7O1Mt.jpg

 

The template file exists for sure.

 

Why I am getting this error and how I can solve this problem?

Thank you to anyone who can help.

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

I don't think you should specify the full path to the template, should you? Prestashop expects your template to be:

/modules/<your-module>/views/templates/front/all-products.tpl

With the above your code you should just be:

$this->setTemplate('all-products.tpl');

That's the standard non-overridden version of your controller's template and I believe there has to be one.

Link to comment
Share on other sites

  • 1 year later...

I had the same problem and I solved it by creating the template file to  <your-site>/themes/default-bootstrap(or the name of your current theme)/modules/<name of the module> and then from your MyModuleAllProductsModuleFrontController, replace 

$this->setTemplate(_PS_THEME_DIR_ . 'all-products.tpl');

to

$this->setTemplate('all-products.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...