Wednesday 20 June 2018

php - Include CSS,javascript file in Yii Framework




How to include a Javascript or CSS file in Yii Framework?



I want to create a page on my site that has a little Javascript application running, so I want to include .js and .css files in a specific view.


Answer



Something like this:



  $baseUrl = Yii::app()->baseUrl; 
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl.'/js/yourscript.js');

$cs->registerCssFile($baseUrl.'/css/yourcss.css');
?>

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...