simon
simon

Reputation: 2377

Prestashop 1.7 set-template with header and footer

I am using prestashop 1.7 and have created a front-controller for my module. When I am using setTemplate, it does not include the header and footer just a blank page. I have assigned a page (in backoffice) to the module controller, and in the module, I am using following code:

/modules/somemodules/controllers/front/moduleslist.php:

class somemodulesmoduleslistModuleFrontController extends ModuleFrontController
{

  public function initContent(){

    $this->context->smarty->assign(array(
      'id' => 1,
    ));

    $this->setTemplate('module:somemodules/views/templates/front/find-modules.tpl');
  }

}

What I have tried in the template file:

/modules/somemodules/views/templates/front/find-modules.tpl:

{extends file='page.tpl'}
{block name='page_content'}
  {{$id}}
{/block}

But now errors is like, undifined language, undifined page etc. Is there a better way of doing this, rather than re-defining all of these?

Upvotes: 2

Views: 1773

Answers (1)

TheDrot
TheDrot

Reputation: 4337

You also have to call the parent method so that all standard variables get initialized.

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

    $this->context->smarty->assign(array(
      'id' => 1,
    ));

    $this->setTemplate('module:somemodules/views/templates/front/find-modules.tpl');
}

Upvotes: 1

Related Questions