php - Yii framework : Load css & js in layout defined by controllers? -


my target include difference css (or js )for difference page. , code link css locate @ layout file.

my first idea pass variable layout, way pass variable view, found "can not design" yii framework forum.

so how putting <link rel="stylesheet" ... > in header (which inside layout file) ?

please correct me if concept wrong.

you want go actions, , register css file them. example:

function actionindex() {     $cs = yii::app()->getclientscript();     $cs->registercssfile(yii::app()->getbaseurl() . '/css/mystyle.css');     $cs->registerscriptfile(yii::app()->getbaseurl() . '/js/myscript.js');      // more stuff } 

you can pass script loader (not css) parameter decide goes, so:

// load on document ready $cs->registerscriptfile(yii::app()->getbaseurl() . '/js/myscript.js', cclient::pos_ready);  

see documentation further help.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -