Ankit Agrawal
Ankit Agrawal

Reputation: 6124

Call Module in tpl file in prestashop

I want to use search module in my header.tpl file . In that i used this code

{include file='./modules/blocksearch/blocksearch.tpl'}

But it's not working and by using this code my page gets blank.

Thanks in advance

Upvotes: 4

Views: 13732

Answers (2)

armandbertea
armandbertea

Reputation: 129

Here you will find what you are looking for http://www.ecartservice.net/prestashop-articles/1-4-plugins-revisited-part-1/

It is a great and easy way to call modules directly in template files, without the use of hooks. I tested it in both Prestashop 1.4 and 1.5 and it works.

For Prestashop 1.5, you will need to create 2 extra files in the "override" folder, as described in the link above:

  • Plugin.php in /override/classes/
  • FrontController.php in /override/classes/controller/

Then, you will be able to use in the template files the following code:

{plugin module='editorial' hook='displayHome'}

You need to use the hook's name (displayHome) and NOT the alias (home).

Upvotes: 4

SJousse
SJousse

Reputation: 711

You cannot include a module template like this because the PHP code of te module is not called and the template needs it to set some Smarty variables.

The best you can do is to hook the blocksearch module to your header. Here we go :

  • Navigate to "admin > modules > positions"
  • Click on "Transplant a module" button
  • Select "Quick Search Block" for "Module"
  • Select ""Header of pages / displayHeader" for "Hook into"
  • Click "Save"

The "Quick Search module" is now hooked to your header.

Upvotes: 3

Related Questions