Home / Web Engineering / Working with css, images, and jQuery in CodeIgniter

Working with css, images, and jQuery in CodeIgniter

Print Friendly

I spent a lot of time for seeking an appropriate solution to use external stylesheets in CodeIgniter. If you are not patient, I think you will give up the racing.

Here is the silver point I have found. It can be described briefly as follows:

Typically, create an “assets” directory for files that need to be accessed like the following:

-application
-system
-assets
—images
—scripts
—styles

Pay attention to that all file references are usually based upon the index.php file. This means you would access a css file via “assets/styles/mystyle.css”

When I want to use a stylesheet and javascript links, I usually do the following:

<link href="<?php echo base_url().'assets/styles/style.css';?>" rel="stylesheet" type="text/css" />

You could try several instructions as follows:

http://stackoverflow.com/questions/5450095/codeigniter-simple-base-url-question

http://ellislab.com/forums/viewthread/62527/

comments

About Nguyen Vu Ngoc Tung

I love making new professional acquaintances. Don't hesitate to contact me via nguyenvungoctung@gmail.com if you want to talk about information technology, education, and research on complex networks analysis (i.e., metabolic networks analysis), data analysis, and applications of graph theory. Specialties: researching and proposing innovative business approaches to organizations, evaluating and consulting about usability engineering, training and employee development, web technologies, software architecture.