register a script file in assets

in a component extending CWidget I do



<?php 


	$foo=$this->controller->clientScript; 


	$foo->registerBodyScriptFile(dirname(__FILE__).'/fDimensions.js');


?>


and it includes the file at the bottom of the document. but the url of the src tag is the original one (under protected so it isn't unreachable by the web server).

what do I have to do to publish a js file in assets?

solved.



<?php


	$clientScript=$this->controller->clientScript; 


	$clientScript->registerBodyScriptFile(Yii::app()->assetManager->publish(dirname(__FILE__).'/fDimensions.js'));


?>





Quote

solved.


<?php


	$clientScript=$this->controller->clientScript; 


	$clientScript->registerBodyScriptFile(Yii::app()->assetManager->publish(dirname(__FILE__).'/fDimensions.js'));


?>





Does this script file belong to 3rd part?

Eg:I want to use a calender.js ,how to make it run in a php file?

You make an extension under protected/extensions and then for example:

<?php


$dir = dirname(__FILE__).DIRECTORY_SEPARATOR.'colorpicker';


$baseUrl =Yii::app()->getAssetManager()->publish($dir);


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


$cs->registerScriptFile($baseUrl.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'colorpicker.js');

in your init or run methods.