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
1 |
clientScript->registerCoreScript |
and
1 |
clientScript->registerCssFile |
functions. Please see the code below.
1 2 3 4 5 6 7 |
<?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');?> |