aymeric69001 Posted February 8, 2020 Share Posted February 8, 2020 Hello, I need to create a custom page for a client on Prestashop, so I am using a module front controller, but I cannot find a way to call a template that I created in the theme, i.e, I created themes/mytheme/templates/custom_template.tpl (which call other templates of the theme) and I want to display this template in the module front controller like this: public function initContent() { // Exemple taken from the doc for a template belonging to the module //$this->setTemplate('modules:cheque/views/templates/front/validation.tpl'); // What I would like to do $this->setTemplate('themes:mytheme/templates/custom_template.tpl'); } Why I don't create a template inside the module folder ? Because I really need to use the template from the theme. Any one has a solution for this ? Thanks a lot Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 10, 2020 Share Posted February 10, 2020 Hi, Use smarty extend in your module template. Exemple : in /modules/{my_module}/views/templates/front/module_template.tpl {extends file='catalog/listing/product-list.tpl'} {block name='product_list_header'} <div class="my-header">....<div> {/block} The module template 'module_template.tpl' use theme template 'product-list.tpl'. Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 10, 2020 Share Posted February 10, 2020 I use this method in my modules and it works very well. Why would you think otherwise? Do you have an example where it doesn't work? Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 10, 2020 Share Posted February 10, 2020 It work in module_name/views/templates/front You can try with this sample module https://github.com/frederic-benoist/fbsample_messageoftheday In the front controller you can see : $this->setTemplate('module:fbsample_messageoftheday/views/templates/front/default.tpl'); And in the template : {extends file=$layout} {block name='content'} <section id="main" class="messages-list"> <h1>{l s='Messages' mod='fbsample_messageoftheday'}</h1> <div class="card-columns"> {foreach from=$messages item=message} <div class="card"> <div class="card-header">{$message.title}</div> <div class="card-body">{$message.message|cleanHtml nofilter}</div> </div> {/foreach} </div> </section> {/block} Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 10, 2020 Share Posted February 10, 2020 I just did a new test and it works very well with any template in a module front controller. You can try it with {extends file="catalog/listing/product-list.tpl"} if you want. Can you give me an example where it doesn't work ? Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 10, 2020 Share Posted February 10, 2020 Thank you I use the smarty extend function in the example controllers used during the trainings for developers and integrators at PrestaShop. So I'm very interested to know the cases where it doesn't work. Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 10, 2020 Share Posted February 10, 2020 So we agree. it works with extends it doesn't work with include. I think the right solution for @aymeric69001 would be: Create a template in the themes directory : mytheme/templates/custom_template.tpl Create a template in the modules directory : mymodule/views/templates/front/my_controller.tpl With in mymodule/views/templates/front/my_controller.tpl : @extend "custom_template.tpl" Link to comment Share on other sites More sharing options...
aymeric69001 Posted February 11, 2020 Author Share Posted February 11, 2020 Thanks, indeed it is working, but I changed my mind and would like to put these custom pages directly into my theme folder, so I will open a new thread on how to have a module belonging to the theme folder (in themes\mytheme\modules), be installed when the theme is installed. But thank you anyway Aymeric Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now