Wednesday, 15 August 2012

php - When I activate the urlManager in config, can my Yii project not find my self created js folders? -



php - When I activate the urlManager in config, can my Yii project not find my self created js folders? -

my folder structure:

-myproject --assets --css --fonts --images --js get error! cannot find folder? --protected --themes --index.php

what should alter in urlmanager, project can find self created folders?

this how urlmanager looks now:

'urlmanager'=>array( 'urlformat'=>'path', 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),

in view have included:

yii::app()->clientscript->registerscriptfile('js/myscript.js');

you should use

yii::app()->clientscript->registerscriptfile(yii::app()->request->baseurl . '/js/your-script.js', cclientscript::pos_head);

to embed script in layout. can access script view part:

yii::app()->request->baseurl . '/js/your-script.js';

php yii

No comments:

Post a Comment