abriggs Posted March 21, 2020 Share Posted March 21, 2020 Hi All, In previous version of PS, I could render a smarty template from a hook like: $this->context->smarty->assign(array( ... )); return $this->display(__FILE__, 'assets-customers.tpl'); and the view file would be placed in modules\foo\views\templates\hook\assets-customers.tpl The page https://devdocs.prestashop.com/1.7/modules/concepts/hooks/use-hooks-on-modern-pages/ tells us the new styntax for rendering a twig template: return $this->get('twig')->render('assets-customers.twig',[ ... ]); But it doesn't give any clues as to where the template file should live? I've tried it in modules\foo\, modules\foo\views\ & modules\foo\views\templates\hook\ but I awlays get Template "assets-customers.twig" is not defined. Can anyone share a working example of using a Twig template from a hook in a module pls? (Not overriding a built-in template) Thanks! Link to comment Share on other sites More sharing options...
abriggs Posted March 21, 2020 Author Share Posted March 21, 2020 Aha! For anyone else with this problem, I've been poking in the prestashop files and found they've defined a Modules path in Twig. So you can do return $this->get('twig')->render('@Modules/foo/views/assets-customers.twig',[ .... ]); and then put your twig file in modules/foo/views/ 1 1 1 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