Codeigniter Autoload Assets Code
Brought to you by:
criffoh
File | Date | Author | Commit |
---|---|---|---|
Autoload_assets.php | 2011-07-10 | criffoh | [r4] * Now is possible load sepparately css and js f... |
README | 2011-07-10 | criffoh | [r4] * Now is possible load sepparately css and js f... |
Codeigniter Assets I've created this library to make easy using css or js files with views/templates. Its use it is very easy, although with a template it is more useful. How it works This library find css/js files with same name that controller and view, and load these files (if exists): controller.css controller_view.css controller.js controller_view.js You only add the file/s in the corresponding directory, and the library loads automatically it. ¿Easy no? Configuration You can configure directory names in config.php file: $config['assets_dir'] = 'pub'; //Default is pub $config['assets_css_dir'] = 'css'; //Default is css $config['assets_js_dir'] = 'js'; //Default is js Note: assets_css_dir and assets_js_dir works into assets_dir directory So the file structure would see like this: /pub /pub/css /pub/js Note: Don't forget create directories. Calling to the Library In view/template into <head> tag add this code: <?php Autoload_assets::get_css(); Autoload_assets::get_js(); ?> I hope it will be useful. My blog: http://porquero.blogspot.com Help to use libraries here: http://codeigniter.com/user_guide/general/libraries.html