[YII] Add CSS and JS File


Deskripsi
     Berikut adalah cara mengembed file external dari css dan js.

Howto
     1. You must have .css and js file.
   
     2. - your css file path : webroot/Yiiapp/css/[create or copy here]
         - your script file path : webroot/Yiiapp/js/[create or copy here] , if doesn't exist create
            first
   
     3. Add this script to your view
        <?php
        Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/style.css');
        Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/test.js');
        ?>
        * no need to echo in view

     4. now your script and css will connect to view

Post a Comment

Harap gunakan bahasa yang baik dan sopan, terima kasih