Skip to content

Commit bff23f4

Browse files
committed
Tutorial page 1 - Add static routing.
1 parent fd53e6d commit bff23f4

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

application/config/routes.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
/************************************************************************
3+
| Modified by: Travis Calder
4+
| Modify default routing to /[controller]/[method]/[args]
5+
*************************************************************************/
6+
27
/*
38
| -------------------------------------------------------------------------
49
| URI ROUTING
@@ -38,8 +43,11 @@
3843
|
3944
*/
4045

41-
$route['default_controller'] = "welcome";
42-
$route['404_override'] = '';
46+
// $route['default_controller'] = "welcome";
47+
// $route['404_override'] = '';
48+
49+
$route['default_controller'] = 'pages/view';
50+
$route['(:any)'] = 'pages/view/$1';
4351

4452

4553
/* End of file routes.php */

application/controllers/pages.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
3+
class Pages extends CI_Controller {
4+
5+
public function view($page = 'home')
6+
{
7+
if(!file_exists( APPPATH . 'views/pages/'.$page.'.php'))
8+
{
9+
show_404();
10+
}
11+
12+
$data['title'] = ucfirst($page);
13+
14+
$this->load->view('templates/header', $data);
15+
$this->load->view('pages/'.$page, $data);
16+
$this->load->view('templates/footer', $data);
17+
}
18+
}
19+
?>

application/views/pages/about.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h2>About</h2>
2+
<p>A page like this might tell you more about me or my company.</p>

application/views/pages/home.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h2>Home</h2>
2+
<p>This is the homepage for my CodeIgniter tutorial application.</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<strong>&copy; 2011</strong>
2+
<script type="text/javascript">if(!NREUMQ.f){NREUMQ.f=function(){NREUMQ.push(["load",new Date().getTime()]);var e=document.createElement("script");e.type="text/javascript";e.src=(("http:"===document.location.protocol)?"http:":"https:")+"//"+"js-agent.newrelic.com/nr-100.js";document.body.appendChild(e);if(NREUMQ.a)NREUMQ.a();};NREUMQ.a=window.onload;window.onload=NREUMQ.f;};NREUMQ.push(["nrfj","beacon-5.newrelic.com","eb488e72a1","2666983","NgEEZBYHDUFWVk0KWg9LJUUXEgxfGFZWB1AIAwhZEAMRHUJGXBEYBhEPVAFGThJyWVUKRi0FBA==",0,32,new Date().getTime(),"","","","",""]);</script></body>
3+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<head>
3+
<title><?php echo $title ?> - CodeIgniter 2 Tutorial</title>
4+
</head>
5+
<body>
6+
<h1>CodeIgniter 2 Tutorial</h1>

0 commit comments

Comments
 (0)