18 Feb 2015
Include JavaScript and CSS file in Yii Framework
Include JavaScript and CSS file in Yii Framework
While working on a project in YII in beginning I came to know a very nice way of including JavaScript and CSS style files in the Layout / View file in YII Framework.
In YII we use
clientScript->registerCoreScript
and
clientScript->registerCssFile
functions. Please see the code below.
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?> <?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/styles/site.css');?> <?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/register_validation.js');?>