Assets and modules

Is the main assets folder available to modules? I tried to call a method in a module view file from a javascript library that was in my main assets folder and it didn’t work. Did I miss something or is the main assets folder not available to modules?

Thanks for any insight.

there is only one public accessable assets dir . managed by assetManager application component. and you can use it anywhere to publish your private assets dir

but you could mimic the thoughts and create a assets dir for your module .

the access way you can refer to the great GII module . and read it , i promise you can learn more techs from it .

good luck :lol:

Basically, you work against Yii’s ‘asset manager’ and ask it to ‘publish’ some assets that your module has. You shouldn’t care how, where and why it does what it does. The publish() call returns the URL you then plant in your views files (to be referenced from client side).

That’s in a nutshell. Of course, you can deviate from this typical path and do things your own way. I strongly recommend first learning how things are done in the ‘traditional way’ in Yii, and only once you understand them well - consider your approach/design.

I strongly recommend reading this good wiki article to better understand ‘Yii assets’.

Is this assets folder is used for caching purpose by the yii application?

Nope. Caching is served by other parts of Yii.

The assets folder is a publicly available folder while the entire /protected folder is… as its name implies - protected, and cannot be accessed directly from the web (and should not). Since the entire application, including your extensions and modules rest inside /protected, you need to somehow ‘publish’ the needed ‘assets’, and here we go back to the links already given above on the subject of the assets manager and ‘publishing’ of assets.