TempleClause Posted January 16 Share Posted January 16 Hey there, Using prestashop 8. I wrote a module that assigns data for the delivery-slip pdf. Something like this: public function hookDisplayPDFDeliverySlip($hookArgs) { $hookArgs['object']->my_param = "hello world"; } But now I would also need some params in the header.tpl. What have I tried: public function hookDisplayPDFDeliverySlip($hookArgs) { $this->context->smarty->assign([ 'test1234' => 'hello world test1234', ]); } But this `test1234` variable is not available in `header.tpl` nor in `delivery-slip.tpl`. What other solutions i have thought about: - Override the `HTMLTemplate.php` file to add custom logic. I would rather not like to do that because updates will become hard - Create my own pdf generator like described here: https://devdocs.prestashop-project.org/8/modules/concepts/pdf/#code-example. Would be very overkill and I would need to basically copy the existing delivery slip generator and just modify slightly. Again it would be hard to update. What's the recommended approach for this problem? Thanks! Link to comment Share on other sites More sharing options...
TempleClause Posted January 16 Author Share Posted January 16 Finally found a solution. I realised that smarty is also passed as an argument so you can do this: public function hookDisplayPDFDeliverySlip($hookArgs) { $smarty = $hookArgs['smarty']; $smarty->assign('test1234', "hello world"); } this variable will than be available both in `delivery-slip.pdf` and `header.tpl` Link to comment Share on other sites More sharing options...
Divine Posted January 21 Share Posted January 21 Don't forget to edit your first post and to add [Solved] in the title 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