omerdavid Posted August 2, 2015 Share Posted August 2, 2015 Hello I am trying to pass smarty variable from controller to tpl,when i am using override in the categoryController i can use this variable in the product-list.tpl,but when i tried to use it in my home-page that also uses the product-list.tpl it will not work, i tried to assign, in the indexController.php--didn't work, also if when override the productController.php i dont see the assigned variable in the product.tpl ,only when codding the productControllerCore directly i can use the variable in the product.tpl . the Variable i am trying to pass is $this->context->smarty->assign(array( 'BASE_ROOT_DIR' => _PS_ROOT_DIR_)); Thanx Link to comment Share on other sites More sharing options...
omerdavid Posted August 3, 2015 Author Share Posted August 3, 2015 Anybody ? Link to comment Share on other sites More sharing options...
razaro Posted August 3, 2015 Share Posted August 3, 2015 Think you can use this in tpl file $smarty.const._PS_ROOT_DIR_ https://github.com/PrestaShop/PrestaShop/blob/fbe174506f99ae0d79e03ac06cd3e9420e94f6a3/themes/default-bootstrap/modules/blocklayered/blocklayered.tpl#L90 But in general, if you want to have some variable in several controllers you can override FrontController but watch where you assign variable and when you call parent function. Also do not forget to clear cache. Link to comment Share on other sites More sharing options...
omerdavid Posted August 4, 2015 Author Share Posted August 4, 2015 Thanx a lot ,it works good,but steel i wanted to know which specific controller is used with product-list home-page ? and how come when using product-list.tpl in category page the var exist and when home-page using product-list.tpl there is no var? Link to comment Share on other sites More sharing options...
razaro Posted August 4, 2015 Share Posted August 4, 2015 On homepage product-list.tpl is used by modules: homefeatured, blocknewproducts and beatsellers. Link to comment Share on other sites More sharing options...
omerdavid Posted August 4, 2015 Author Share Posted August 4, 2015 In controller i am adding the var assign in function initContent(),what is the right function to assign var, in moduls ? Link to comment Share on other sites More sharing options...
razaro Posted August 4, 2015 Share Posted August 4, 2015 It depends on module, how it is organised, but usually you need to add it to some displayHookHome that already exists. Note that in latest versions you can override modules (its php files) too, there is one topic on forum with some explanation. Also try to not use overrides when you do not need it, and check if it is possible to do task in different way. Maybe some custom module that hooks into some existing hook in product-list.tpl, or even add your own custom hook. Link to comment Share on other sites More sharing options...
omerdavid Posted August 4, 2015 Author Share Posted August 4, 2015 for example, i would like to add suppliers to orders in BO ,while trying to do so i understood that i need to override the adminOrderController.php and to add _select and _join, how do i know when it will be better to use module rather than override ? Link to comment Share on other sites More sharing options...
razaro Posted August 4, 2015 Share Posted August 4, 2015 Note that is different question and you should make new topic for it. But if you make changes to just one store you can use just overrides. If you need more functionality and options you can make a module that on install overrides that adminOrderController. Just note that using overrides can get to some issues, for example when few modules wants to override same controller. Then conflict appears and you have to manually combine code. Also check PrestaShop documentation and github, think there are few new hooks added for order page, so you can hook module to it and show suppliers like that. Link to comment Share on other sites More sharing options...
omerdavid Posted August 4, 2015 Author Share Posted August 4, 2015 OK thanx,it helped me a lot... 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