prestashop_newuser Posted October 8, 2013 Share Posted October 8, 2013 Hi, I am doing a small module. In that I have my hookTop function is like this public function hookTop($params){ global $cookie, $smarty; $value=array(); $sql_select="SELECT * FROM "._DB_PREFIX_."tablename"; $value=Db::getInstance()->ExecuteS($sql_select); $smarty->assign('array',$value); $smarty->assign('default',$defaultLanguage); return $this->display(__FILE__, 'modulename.tpl'); } and in hookheader where I have added all the js like this public function hookHeader() { $this->context->controller->addCSS(($this->_path).'css/styles.css', 'all'); $this->context->controller->addJS(($this->_path).'js/modulename.js', 'all'); $this->context->controller->addJS(($this->_path).'js/jquery.cycle.lite.js', 'all'); } Now I want to use one value which will be fetched from the database in public function hookTop($params){.....} and that value will be used in one of my externale .js file. So can someone kindly tell me how to send the php value to an external jquery file and use that particaular value in a js file? Any help and suggestions will be really appreciable. Thanks Link to comment Share on other sites More sharing options...
vekia Posted October 8, 2013 Share Posted October 8, 2013 hello you can create variable in smarty template, just pass it to the smarty array and then, in template file use: <script type="text/javascript"> var myVariable = '{$myVariable}'; </script> 1 Link to comment Share on other sites More sharing options...
prestashop_newuser Posted October 9, 2013 Author Share Posted October 9, 2013 hello you can create variable in smarty template, just pass it to the smarty array and then, in template file use: <script type="text/javascript"> var myVariable = '{$myVariable}'; </script> Thanks..That worked like a charm.. Link to comment Share on other sites More sharing options...
vekia Posted October 9, 2013 Share Posted October 9, 2013 glad to hear that i could help you im going to mark this topic as [solved] with regards, Milos Link to comment Share on other sites More sharing options...
Recommended Posts