Simple question: I have a javascript and some of the code is depended on model constants etc. so this is why I have php inside this code. I guess the code $cs->registerScriptFile(’/javascript/somefile.js’); is out of the question. Am I correct?
Currently I have renamed somefile.js to --> somefile.php and use the require(‘somefile.php’) to get the same result.
Thank you very much for clarifying it. In case someone has the same problem, below is the solution. Ok I stuck in a moment how to get the contents of a php file after being processed in the server and the get_include_contents function was the solution
function get_include_contents($filename)
{
if (is_file($filename))
{
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
return false;
}
$somescript= get_include_contents($somefilepath);
$cs=Yii::app()->getClientScript();
$cs->registerScript($somefilepath, $somescript);