I've just started learning about HMVC in CodeIgniter.
So far I've been enjoying having modular controllers, but problems come when I wish to include javascript.
It seems to me that I'll have to include javascript file from the view instead of the widgets which isn't really good because I tend to forget which widgets has to come with which javascript file.
Anyone has a better way to do it?
Assets (css,js,images) you should place outside of application folder so you can access them directly.
Thus , you load them using base_url() to start with, and base_url() remains same from wherever you call it.
if you want to split assets in modules as well, perhaps make an assets folder, which further contains folders with module names, each containing css,js,images files. then use base_url()."/assets/module_name/js/script.js"
or something of the sort
As default, you cannot access files within your module folder as it was protected by .htaccess in applications folder.
To allow access in your assets/public folder within your module folder just add another .htaccess within the folder and add the following line.
Allow From All
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With