Jump to content

Override module template layout


xiparos

Recommended Posts

Hi Prestashop member,

 

I'd like to know if there is a way to override tpl file layout (not itself ) in a module ?

 

For example, in blockwishlist module, I wish to display only content form, without displaying header, footer or left column section after clicking "my wish list" link.

 

What I found is by overriding default ModuleFrontController in /prestashop/override/controllers/front/ModuleFrontController can partially make it right, ( I got errors somewhat). that's what I've done:

public function __construct()
    {
        $this->controller_type = 'modulefront';

        $this->module = Module::getInstanceByName(Tools::getValue('module'));
        if (!$this->module->active)
            Tools::redirect('index');

        parent::__construct();

        if(strcasecmp($this->module->name, 'blockwishlist') === 0)
        {
            $this->display_column_left = false;
            $this->display_column_right = false;
            $this->display_header = true;
            $this->display_footer = false;
        }


    }

That will display only header when clicking "my wish list" link, but I got smarty_internal_template error when I switch to $this->display_header = false.

 

PS: I already know we could override default template file by creating a layout-xxx.tpl within /prestashop/theme/default-bootstrap/override/ to override xxx.tpl in theme directory.

 

Is there a similar way to override template layout for tpl file in a module ? Please help me to figure out.

 

Thanks a lot.

 

Regards

 

 

Link to comment
Share on other sites

Your approach sounds good. Anyway, HEADER is used for a lot of things, like loading js/css, assign smarty variables, etc..

Another option for you: using "HOOK EXCEPTION".

 

First, go to Modules > Positions and list all modules hooked int HEADER for example. (Do similar things for left, right, footer)>

Now, edit each module (you might have to unhook and hook again) against hook HEADER. Make sure you add an exception for your module controller.

 

Here is the example: I'm trying to remove module Quick Quote Tool pro from hook HEADER.

30a3db56-5b27-11e4-9ca9-69351af052d1.png

It seems time-consuming, right?

 

Who has any other idea?

Link to comment
Share on other sites

Hi TungCEO,

 

Thanks for your reply, I've tested your approach but failed to make it.

 

That's what I did with your approach.

 

post-838955-0-16100100-1414268278_thumb.png

 

When I try to add "hookHeader" exclusion rules to module-blockwishlist-mywishlist page, it appears the errors above.

 

I don't quite understand what does this mean, I think it will exclude hookHeader action from the exception page specified in the list, which means the header will not be displayed in the specified page.

 

The example you show to me is available to any module other than wishlist itself ?

 

Thanks in advance.

 

Regards

post-838955-0-16100100-1414268278_thumb.png

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

Hey,

 

The option I show you will be available for most of modules.

Basically the modules which are adapted to PS1.5 (or above) structure are counted in. In means, you will be able to find out the folders controllers/front/ or controllers/admin under that module.

 

I'm afraid that, some of your modules cause the conflict.

Can you paste here here details of the error message?

 

Let me know.

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