grk_ Posted March 7, 2014 Share Posted March 7, 2014 (edited) Hello, so I've been developing a module which would allow me to add different image labels on top of the product images in product list view. Currently plugin hooks onto the header which is not great since that's happening basically on every page, but I can live with that. The problem though is that when pagination is used within product list it uses ajax to refresh the contents of product list and that's where the problem occurs. Because update is made via ajax the header is not loaded again this means that variables that I have assigned to smarty are no longer available within product-list.tpl So the question is how can I get the variables to work after ajax refresh of product-list. TL;DR I need to be able to use smarty variables from my module within product-list.tpl. Currently I'm using header hook, but variables become unavailable as soon as product list has more than 1 page. Is there anyway I can hook prodict-list so that after ajax pagination is used my variables will be available within product-list.tpl Edited March 8, 2014 by grk_ (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted March 8, 2014 Share Posted March 8, 2014 Try adding a new hook to the product-list, inside each element Like {hook h='myInnerHook'} and hook your module there. It should be processed with ajax too. A more in depth explanation here: http://blog.arvixe.com/adding-hooks-to-prestashop-1-5-the-new-way/ Link to comment Share on other sites More sharing options...
grk_ Posted March 8, 2014 Author Share Posted March 8, 2014 Thanks for a suggestion Nemo1 I created a custom hook and placed it in product-list.tpl, unfortunately it still did not help, I was not able access variables within product-list.tpl, but if I used the variables in footer.tpl they worked. So my only guess is that even though the hook is working and is being run in product-list.tpl, variables for the template are already assigned at the time and new variables from the hook only become available when the next template file is processed, for example footer,tpl, but that just a guess Anyway I ended up doing it the other way around, passing variables from the template to module by assigning them within hook call. Link to comment Share on other sites More sharing options...
Recommended Posts