Category Archives: CodeIgniter

How to create static pages in codeIgniter

Create pages.php in controller/ folder.

Add the following codes.

class Pages extends CI_Controller {
public function view($page = 'home')

if ( ! file_exists('application/views/pages/'.$page.'.php'))
// Whoops, we don't have a page for that!

$data['title'] = ucfirst($page); // Capitalize the first letter

$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);


Create header.php and footer.php inside application/view/templates/ folder.

Create about.php inside the folder application/view/pages/

Edit /application/config/routes.php

$route['about'] = 'pages/view/about';

Now we will be able to view the page at http://domainname/index.php/about

CodeIgniter – where to store css,js,fonts and images?

I have the set up like this.

  • application
  • assets
    • css
    • js
    • images
    • fonts

Then inside the folder applications/helpers/ I created the file utility_helper.php with the following code.

function asset_url(){
return base_url().'assets/';

Then inside application/cofig/autoload.php I have added the following code

$autoload['helper'] = array('url','utility');

Now this echo asset_url(); is the path to css, js,fonts and image files.