»
S
I
D
E
B
A
R
«
Using Images, Scripts, CSS inside Code Igniter
May 8th, 2008 by Nitesh

As web developers, we often run into problems while handling various assets such as images, scripts and css files. To make it easier to access and call such assets from within the Code Igniter framework, here is an implementation of the Asset Library, which we have been using at Wallwisher. Hope you find it useful.

Structure

In parallel to the Code Igniter system folder in your implementation, place a new folder called assets. Inside this folder, feel free to describe new assets such as images, scripts, styles and others necessary for your implementation. You need the following files to implement the library:

  1. Configuration File: to be placed in system/application/config/ 
  2. Helper File: to be placed in system/application/helpers/
  3. Library File: to be placed in system/application/libraries/

Examples

Here are a few examples which might help you in understanding the usage of this library:

  1. $new_image = ‘.’.asset_url(‘example.jpg’,'images’);
  2. $CI =& get_instance();   $new_css = $CI->assets->get_asset_from_name(‘css’,$name);
»  Substance: WordPress   »  Style: Ahren Ahimsa