Blog Details

Creating Static pages at CodeIgniter



                                

*Creating First Application at CodeIgniter:-

  1)  First, we make controller, create a file name "pages.php"   Create a file    at application/controllers/pages.php with the following code.   <?php 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!
		show_404();
	}

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

	$this->load->view('templates/header', $data);
	$this->load->view('pages/'.$page, $data);
} }   2) Create the header at application/views/templates/header.php and add the following code.   <html> <head> <title><?php echo $title ?> - CodeIgniter 2 Tutorial</title> </head> <body> <h1>Hello Word</h1>   3) Open the routing file located at application/config/routes.php and add the following two lines.  
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';

 


Categories

CodeIgnitor

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote