Jump to content

[SOLVED] How to use a php value in an external .js file


Recommended Posts

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

×
×
  • Create New...