KenFranklin Posted January 23, 2017 Share Posted January 23, 2017 (edited) How to get variable Configuration::get($var) from *.php file in *.js file? Send Configuration::get($var) value to *.js? Edited January 23, 2017 by ken5 (see edit history) Link to comment Share on other sites More sharing options...
BeComWeb Posted January 23, 2017 Share Posted January 23, 2017 You must assign the variable as a smarty variable using $this->smarty->assign method. Link to comment Share on other sites More sharing options...
KenFranklin Posted January 23, 2017 Author Share Posted January 23, 2017 and I can use it in *.js file? Link to comment Share on other sites More sharing options...
KenFranklin Posted January 23, 2017 Author Share Posted January 23, 2017 not in tpl. in js Link to comment Share on other sites More sharing options...
bellini13 Posted January 23, 2017 Share Posted January 23, 2017 below are 2 ways to accomplish this, but I would suggest #1 1) create a tpl file and use the addJsDef or addJsDefL function. you can review the product.tpl file in the default theme for examples 2) parse the javascript file through the smarty engine as though it was a smarty template. then return the javascript inline Link to comment Share on other sites More sharing options...
Andrej Stas Posted January 23, 2017 Share Posted January 23, 2017 I think this topic could help you out: https://www.prestashop.com/forums/topic/564203-solved-no-jquery-included-in-rc3/?do=findComment&comment=2453760 Basically what Bellini said, but more detailed. Link to comment Share on other sites More sharing options...
keberin Posted January 17, 2018 Share Posted January 17, 2018 Don't know if someone is still looking for the answer personnally I use this method 1)Assign your variable $this->context->smarty->assign('var', $yourphpvar); 2) Use addJsDef Media::addJsDef(array('thejsvarname'=>$yourphpvar); It work on both 1.6 on 1.7 prestashop version 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