ClientScript registerScriptFile Question

Hi!

I´m new to using Yii but loving it already! Theres one thing regarding javascript I need clarification on…

I have stored my Javascripts in JS-files in a folder on the same level as CSS and Images. Can I call a JS-file from this folder and have it´s contents inserted into the <head> part of my layout-file when the layout is rendered?

In my controller file I use:


Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . "/js/myfile.js");

This work fine but it creates a reference to the JS file, like:




<head>

...

<script type="text/javascript" src="/js/myfile.js"></script>

</head>

I would like the JS to be included in the HTML file, like:




<head>

...

<script type="text/javascript">

function foo() {

    alert('bar');

}

</script>

</head>



Is this possible? I would also like to be able to do this with CSS.

Thanks in advance!




Yii::app()->clientScript->registerScript(

	'myscript',

	file_get_contents('path/to/myscript.js'),

	CClientScript::POS_HEAD

);



Ahh, ofcourse. Feels very obvious now =)

Thanks!