Jump to content

why I can't embed my template in the main theme in prestashop 1.7?


Recommended Posts

I'm trying to follow the official guide of prestashop but I am facing 2 issues:

  1. I see the display.tpl as raw text and not embedded in the main theme.
  2. I can't see the message stored in the variable "my_module_message"

 

mymodule.php
 

public function hookDisplayLeftColumn($param)
	{
		$this->context->smarty->assign(
			array(
				'my_module_name' => configuration::get('G2A_NAME'),
				'my_module_link' => $this->context->link->getModuleLink('g2a','display'),
				'my_module_message' => $this->l('This is a simple text message')));

		return $this->display(__FILE__ , 'g2a.tpl');
	}

controllers/front/display.php

class g2adisplayModuleFrontController extends ModuleFrontController
{
  public function initContent()
  {
    parent::initContent();
     $this->context->smarty->assign('my_module_message', $this->l('This is a simple text message'));
        $this->setTemplate('module:g2a/views/templates/front/display.tpl');
  }
}

views/templates/front/display.tpl

{extends file=$layout}

{block name='content'}
  welcome to my shop!
  {$my_module_message}
{/block}

 

Edited by medoampir
code update (see edit history)
Link to comment
Share on other sites

HI

 

1  you are on 1.7 you need extend the structure of the tpl  for example

{extends file='page.tpl'}

 

2 because you are not send any information you need set the smarty on the frontcontroller

 

 

 

Link to comment
Share on other sites

15 hours ago, jgamio said:

HI

 

1  you are on 1.7 you need extend the structure of the tpl  for example

{extends file='page.tpl'}

 

2 because you are not send any information you need set the smarty on the frontcontroller

 

 

 

none of these solutions worked for me. i'm not sure why.

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