From c5f99fdcc5c4a918b5b8fe3ddbd56ab25ad1c22b Mon Sep 17 00:00:00 2001 From: Wes Baker Date: Mon, 8 Jul 2013 17:22:21 -0400 Subject: Updating User Guide for 2.1.4. --- user_guide/tutorial/static_pages.html | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'user_guide/tutorial/static_pages.html') diff --git a/user_guide/tutorial/static_pages.html b/user_guide/tutorial/static_pages.html index 13e406358..be05436ef 100644 --- a/user_guide/tutorial/static_pages.html +++ b/user_guide/tutorial/static_pages.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.1.3

CodeIgniter User Guide Version Location

@@ -109,15 +109,15 @@ We will be creating two "views" (page templates) that act as our page

CodeIgniter 2 Tutorial

- + -

The header contains the basic HTML code that you'll want to display before loading the main view, together with a heading. +

The header contains the basic HTML code that you'll want to display before loading the main view, together with a heading. It will also output the $title variable, which we'll define later in the controller. Now create a footer at application/views/templates/footer.php that includes the following code:

- + @@ -127,8 +127,8 @@ Now create a footer at application/views/templates/footer.php that in

Earlier you set up a controller with a view() method. The method accepts one parameter, which is the name of the page to be loaded. The static page templates will be located in the application/views/pages/ directory.

-

In that directory, create two files named home.php and about.php. -Within those files, type some text − anything you'd like − and save them. +

In that directory, create two files named home.php and about.php. +Within those files, type some text − anything you'd like − and save them. If you like to be particularly un-original, try "Hello World!".

In order to load those pages, you'll have to check whether the requested page actually exists:

@@ -136,15 +136,15 @@ If you like to be particularly un-original, try "Hello World!".

 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);
 	$this->load->view('templates/footer', $data);
@@ -160,7 +160,7 @@ public function view($page = 'home')
 
 

The last thing that has to be done is loading the views in the order they should be displayed. The second parameter in the view() method is used to pass values to the view. Each value in the $data array is assigned to a variable with the name of its key. So the value of $data['title'] in the controller is equivalent to $title in the view.

- +

Routing

The controller is now functioning! Point your browser to [your-site-url]index.php/pages/view to see your page. When you visit index.php/pages/view/about you'll see the about page, again including the header and footer.

@@ -169,7 +169,7 @@ The second parameter in the view() method is used to pass values to t http://example.com/[controller-class]/[controller-method]/[arguments]

Let's do that. Open the routing file located at application/config/routes.php and add the following two lines. Remove all other code that sets any element in the $route array.

- +
 $route['default_controller'] = 'pages/view';
 $route['(:any)'] = 'pages/view/$1';
-- 
cgit v1.2.3-24-g4f1b