Tuesday, 18 February 2014

How to add assets in CodeIgniter

When you are creating a Web Application with CI, you work with assets

you can create a "assets" folder in the root folder

To activate it

Step 1: Create Application Helper

application/helpers/utility_helper.php
function asset_url(){
   return base_url().'assets/';
}

Step 2: application/config/autoload.php:
$autoload['helper'] = array('url','utility');

After this you can very well use asset_url(); with in your application
 Ref

2 comments:

  1. The article gives a straightforward approach to managing static assets in a CodeIgniter web application by keeping files such as CSS, JavaScript, and images inside an assets folder at the project root. The custom asset_url() helper provides a convenient way to generate the base path for these resources, while autoloading the helper makes the function available throughout the application.

    For developers learning web application structure, this example shows how framework helpers can simplify repetitive path handling and keep asset references consistent. It also provides a practical foundation for learners taking a Web Development Course, where understanding how application resources are organized is an important part of building maintainable web projects.

    ReplyDelete
  2. The use of a dedicated helper also demonstrates how framework configuration and reusable functions can work together rather than placing asset paths directly throughout views. This type of implementation is useful for learners developing broader web-development skills through a Web Development Course, particularly when working with structured application folders and reusable components.

    ReplyDelete