Include View Files

Hello

I am trying to implement Angular js in yii framework, suggest me how i will add js file which is inside view folder. my requirement is to keep angular controller with each module’s view folder separately.

Example:

js file location "view/product/abc.js"

html file location "view/product/xyz.php"

In above example i want to include js(abc.js) file in html(xyz.php) file.

when i am trying to add js file using “Yii::app()->baseUrl.’/protected/views/product/abc.js” syntax, it give me error that " You don’t have permission to access the requested object. It is either read-protected or not readable by the server."

Thanks

The browser is not allowed to read files from the protected directory.

You have to use the assetsmanager to publish the js-file to a public folder first.




  $jsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.views.product.abc').'.js');

  Yii::app()->getClientScript()->registerScriptFile($jsUrl); 




Hi Joblo

Its Working

Thanks :)

hi how to add extension js file into my project in yii framework .i want to add window modal effects by using ModalWindowEffects extension but i dnt knw how to add a js file into my project…Anyone help me!!