Include Javascript And Css

Including Javascript And Css

 $baseUrl = Yii::app()->baseUrl; 

  $cs = Yii::app()->getClientScript();



Thank you.

How to include the css files in header and the .js files in footer of the site?

Styles will be registered a head tag.

To place js at desired position you need to pass second parameter of registerScriptFile() method



$cs->registerScriptFile($baseUrl.'/js/yourscript.js', CClientScript::POS_END);


[size=“2”]There’s a convenient practice also to configure default scripts position this way (put it to ‘components’ section of your config file):[/size]


'clientScript' => array(

	'class' => 'CClientScript',

    'coreScriptPosition' => CClientScript::POS_END,

    'defaultScriptFilePosition' => CClientScript::POS_END,

    'defaultScriptPosition' => CClientScript::POS_READY,