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.

Limit the number of sticky posts appearing on site

Code to limit the number of sticky posts shown in a page

/* Get all sticky posts */
$sticky = get_option( ‘sticky_posts’ );

/* Sort the stickies with the newest ones at the top */
rsort( $sticky );

/* Get the 2 newest stickies (change 5 for a different number) */
$sticky = array_slice( $sticky, 0, 5 );

/* Query sticky posts */
query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1 ) );

WordPress in AWS micro istance

I am currently running this wordpress blog in AWS micro instance to see how it goes.

I find some issues.

Atelease once in a week I can not connect to phpmyadmin using master password.

When I check the phpmyadmin folder I see that does not contain password or anything.

Added them back and fixed the issue.

Another issue I find is I can not restart mysql server.

It gives the following error

Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

I have restarted the EC2 instance, then restrated apache and mysql, everything is back.

It looks like the MySQL database crashed because the micro EC2 instance that I was using didn’t have enough processing power to handle the wordpress queries. This is a basic wordpress blog without much plugins, so looks like micro instance is not good enough to run wordpress.

The notes I am writing here help me (perhaps others as well) to remember the solutions I figured out for the Wordpress / PHP issues that I have come across …