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
Post a Comment