Andrej Stas Posted October 20, 2016 Share Posted October 20, 2016 (edited) We are developing Blog Module for Prestashop 1.7. This is our new problem now: in our_module/controllers/front/some_file.php we call $this->setTemplate('blog.tpl'); Blog.tpl really exists: our_module/views/templates/front/blog.tpl However, we are getting this error (see screenshot) This is working correctly in RC1, not working in RC2 EDIT: not working also in RC3 Edited October 30, 2016 by Andrej Stas (see edit history) 2 Link to comment Share on other sites More sharing options...
Andrej Stas Posted October 30, 2016 Author Share Posted October 30, 2016 Anyone else struggling with this? Link to comment Share on other sites More sharing options...
bellini13 Posted October 30, 2016 Share Posted October 30, 2016 is it view or views? Link to comment Share on other sites More sharing options...
Andrej Stas Posted October 30, 2016 Author Share Posted October 30, 2016 is it view or views? I made a typo in that post, we have "views" folder. Link to comment Share on other sites More sharing options...
bellini13 Posted October 30, 2016 Share Posted October 30, 2016 try without the .tpl extension $this->setTemplate('blog'); Link to comment Share on other sites More sharing options...
Andrej Stas Posted October 31, 2016 Author Share Posted October 31, 2016 You are right, it should be written as "blog" instead of "blog.tpl", but my problem still persists. I found out that Prestashop is always searching for this "blog.tpl" only in the "theme" folder. But in my case, the TPL files are saved in the module folder our_module/views/templates/front/blog.tpl Link to comment Share on other sites More sharing options...
eleazar Posted October 31, 2016 Share Posted October 31, 2016 I'm not sure, but maybe this helps: https://github.com/PrestaShop/PrestaShop/commit/069bb663b475a9dfe6ab8d1b65f946c0688d5025#diff-d14938f32c33c9dfc0a8722cfbb17737 Link to comment Share on other sites More sharing options...
Andrej Stas Posted October 31, 2016 Author Share Posted October 31, 2016 I'm not sure, but maybe this helps: https://github.com/PrestaShop/PrestaShop/commit/069bb663b475a9dfe6ab8d1b65f946c0688d5025#diff-d14938f32c33c9dfc0a8722cfbb17737 Hmmm, thank you, but not really. Prestashop doesn't try to search for the blog.tpl in my module, but only in the theme. It was working well in RC1 Link to comment Share on other sites More sharing options...
Yoddle Posted November 4, 2016 Share Posted November 4, 2016 Hello! I got the same problem. setTemplate() tries to find the template file in the theme directory. More specifically, in "templates/fr-FR" (or "templates/en-EN", "templates/es-ES"... depend on the shop language). Are we supposed to use another function to load templates in 1.7? Link to comment Share on other sites More sharing options...
razaro Posted November 4, 2016 Share Posted November 4, 2016 Think you should use fetch http://developers.prestashop.com/module/80-Updating/index.html?highlight=fetch for example https://github.com/PrestaShop/ps_sharebuttons/blob/master/ps_sharebuttons.php#L132 Link to comment Share on other sites More sharing options...
Yoddle Posted November 4, 2016 Share Posted November 4, 2016 Think you should use fetch http://developers.prestashop.com/module/80-Updating/index.html?highlight=fetch for example https://github.com/PrestaShop/ps_sharebuttons/blob/master/ps_sharebuttons.php#L132 I thought that fetch() was meant to replace display(), as it returns the content of the template. setTemplate() is a method of ModuleFrontController class, usually use in the initContent() method, it does not directly return the content of the template. I'm a little bit confused :s Link to comment Share on other sites More sharing options...
razaro Posted November 4, 2016 Share Posted November 4, 2016 Yes you are right my bad. In initContent() method maybe something like this $this->setTemplate('module:our_module/views/templates/front/blog.tpl'); Example also in https://github.com/PrestaShop/ps_emailsubscription/blob/master/controllers/front/verification.php#L50 And about languages not sure how it is for module but here is some info about template hierarchy, but as I understand for themes mostly. https://github.com/PrestaShop/PrestaShop/pull/5809 1 Link to comment Share on other sites More sharing options...
Yoddle Posted November 7, 2016 Share Posted November 7, 2016 (edited) I tried with a path like 'module:our_module/views/templates/front/blog.tpl' : It loads the template, but not the layout. I only got the template content, nothing else, no css, no js, not a single piece of the theme html. And I can't find any parameter for initContent or setTemplate that specify if we want just the template or the whole page. What am I doing wrong? Edited November 7, 2016 by Yoddle (see edit history) Link to comment Share on other sites More sharing options...
stradinov Posted November 7, 2016 Share Posted November 7, 2016 Is this bug reported? Today 1.7 version was released and the issue is still there. Any solution? Link to comment Share on other sites More sharing options...
JA MODULES Posted November 8, 2016 Share Posted November 8, 2016 Hello,I have the same problem but I can not solve with the last indication. Is not there another solution?Regards Link to comment Share on other sites More sharing options...
Yoddle Posted November 8, 2016 Share Posted November 8, 2016 Thanks! But is it the official new way to deal with template in module front controller or just a work around? In the new 1.7 dev documentation (http://developers.prestashop.com/module/05-CreatingAPrestaShop17Module/05-DisplayingContentOnTheFrontOffice.html), as far as I understand, setTemplate is supposed to work exactly like in 1.6 Any way to get an official answer? Link to comment Share on other sites More sharing options...
Andrej Stas Posted November 9, 2016 Author Share Posted November 9, 2016 Thank you very much! Link to comment Share on other sites More sharing options...
abdess Posted February 12, 2017 Share Posted February 12, 2017 I have the same problem Is there any solution? 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