Position of JS/CSS added by register packge

I got this here where there is written u can add js file and script at this position… how do i use this positions with registerPackgae… i try to find in documentation… but it is not menstioned… do i use this with register Package…?

the position of the JavaScript code. Valid values include the following:

CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.

CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.

CClientScript::POS_END : the script is inserted at the end of the body section.

CClientScript::POS_LOAD : the script is inserted in the window.onload() function.

CClientScript::POS_READY : the script is inserted in the jQuery’s ready function.

you can configure cliemtScript application component in main.php config as follows:




/**

	 * @var integer Where the scripts registered using {@link registerCoreScript} or {@link registerPackage}

	 * will be inserted in the page. This can be one of the CClientScript::POS_* constants.

	 * Defaults to CClientScript::POS_HEAD.

	 * @since 1.1.3

	 */

	public $coreScriptPosition=self::POS_HEAD;

	/**

	 * @var integer Where the scripts registered using {@link registerScriptFile} will be inserted in the page.

	 * This can be one of the CClientScript::POS_* constants.

	 * Defaults to CClientScript::POS_HEAD.

	 * @since 1.1.11

	 */

	public $defaultScriptFilePosition=self::POS_HEAD;

	/**

	 * @var integer Where the scripts registered using {@link registerScript} will be inserted in the page.

	 * This can be one of the CClientScript::POS_* constants.

	 * Defaults to CClientScript::POS_READY.

	 * @since 1.1.11

	 */

	public $defaultScriptPosition=self::POS_READY;



as you can see ‘coreScriptPosition’ stands for ‘coreScripts’ but also for 'registerPackage’s…

]

thanks for the answer… but what i want to do … is load the whole package scripts after the page got loaded… i am doing this right now…


        


'clientScript'=>array(

            'packages'=>array(


                'jquery'=>array(

                    'baseUrl'=> 'siteasset/jquery' ,

                    'js'=>array(YII_DEBUG ? 'jquery.js' : 'jquery.min.js'),

                    'position'=>CClientScript::POS_END

                ),


                'jquery.ui'=>array(

                    'baseUrl'=> 'siteasset/jquery.ui' ,

                    'js'=>array(YII_DEBUG ? 'jquery-ui.js' : 'jquery-ui.min.js'),

                    'depends'=>array('jquery'),

                    'position'=>CClientScript::POS_END

                ),


                'jquery.ui.css'=>array(

                    'baseUrl'=> 'siteasset/jquery.ui' ,

                    'css'=>array(YII_DEBUG ? 'jquery-ui.css' : 'jquery-ui.min.css'),

                    'position'=>CClientScript::POS_HEAD

                ),


                'bootstrapCss'=>array(

                    'baseUrl'=> 'siteasset/bootstrap/css' ,

                    'css'=>array(YII_DEBUG ? 'bootstrap.css' : 'bootstrap.min.css', YII_DEBUG ? 'bootstrap-theme.css' : 'bootstrap-theme.min.css' ),

                    'position'=>CClientScript::POS_HEAD

                ),


                'fontAwesomeCss'=>array(

                    'baseUrl'=> 'siteasset/fontAwesome/css' ,

                    'css'=>array(YII_DEBUG ? 'font-awesome.css' : 'font-awesome.min.css'),

                    'position'=>CClientScript::POS_HEAD

                ),


                'bootstrapJs'=>array(

                    'baseUrl'=> 'siteasset/bootstrap/js',

                    'js'=>array(YII_DEBUG ? 'bootstrap.js' : 'bootstrap.min.js'),

                    'depends'=>array('jquery'),

                    'position'=>CClientScript::POS_END

                )

            )

  )



This is what i am doing right now … Is this correct way of doing… because when i var_dump the CClientScript object It shows the depends key value but it do not show the position value… May be the position thing is only works with registerScriptFile (CClientScript::POS_HEAD, CClientScript::POS_BEGIN, CClientScript::POS_END)

and registerScript

(CClientScript::POS_HEAD, CClientScript::POS_BEGIN, CClientScript::POS_END, CClientScript::POS_READY, CClientScript::POS_LOAD)

on the basis of documentation … If there will be position for registerPackage then it will be awesome… i think for registerPackage it is only CClientScript::POS_HEAD… if i am wrong then pls correct me…?

hey i found this

Yii::app()->clientScript->coreScriptPosition=CClientScript::POS_HEAD;

now i can add javascripts to at end… but it sets for all coreScripts (for all the package)… but what if some one want to load all css Package in head section and all js in the POS_END

thanks now its working…!!! Just there was my mistake … i vas print_r() in controller so… it was not loading properly…

now i am doing this in controller.php in components…

        Yii::app()->clientScript->coreScriptPosition=CClientScript::POS_HEAD;


        $cs->registerPackage('jquery.ui.css');


        $cs->registerPackage('bootstrapCss');


        $cs->registerPackage('moslakeMadeCss');


        $cs->registerPackage('fontAwesomeCss');





        Yii::app()->clientScript->coreScriptPosition=CClientScript::POS_END;


        $cs->registerPackage('jquery');


        $cs->registerPackage('jquery.ui');


        $cs->registerPackage('bootstrapJs');

More about…CSS Positioning