fixed code block spacing on URLs and Views general docs
diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst
index 296271e..db1ffe5 100644
--- a/user_guide_src/source/general/urls.rst
+++ b/user_guide_src/source/general/urls.rst
@@ -42,9 +42,13 @@
You can easily remove this file by using a .htaccess file with some
simple rules. Here is an example of such a file, using the "negative"
-method in which everything is redirected except the specified items::
+method in which everything is redirected except the specified items:
- RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
+::
+
+ RewriteEngine on
+ RewriteCond $1 !^(index\.php|images|robots\.txt)
+ RewriteRule ^(.*)$ /index.php/$1 [L]
In the above example, any HTTP request other than those for index.php,
images, and robots.txt is treated as a request for your index.php file.
@@ -74,7 +78,9 @@
your application/config.php file. If you open your config file you'll
see these items::
- $config['enable_query_strings'] = FALSE; $config['controller_trigger'] = 'c'; $config['function_trigger'] = 'm';
+ $config['enable_query_strings'] = FALSE;
+ $config['controller_trigger'] = 'c';
+ $config['function_trigger'] = 'm';
If you change "enable_query_strings" to TRUE this feature will become
active. Your controllers and functions will then be accessible using the
@@ -82,7 +88,7 @@
index.php?c=controller&m=method
-**Please note:** If you are using query strings you will have to build
-your own URLs, rather than utilizing the URL helpers (and other helpers
-that generate URLs, like some of the form helpers) as these are designed
-to work with segment based URLs.
+..note:: If you are using query strings you will have to build
+ your own URLs, rather than utilizing the URL helpers (and other helpers
+ that generate URLs, like some of the form helpers) as these are designed
+ to work with segment based URLs.
diff --git a/user_guide_src/source/general/views.rst b/user_guide_src/source/general/views.rst
index cb60ce2..7d0acca 100644
--- a/user_guide_src/source/general/views.rst
+++ b/user_guide_src/source/general/views.rst
@@ -20,10 +20,17 @@
===============
Using your text editor, create a file called blogview.php, and put this
-in it:
+in it::
-<html> <head> <title>My Blog</title> </head> <body> <h1>Welcome to my
-Blog!</h1> </body> </html>
+ <html>
+ <head>
+ <title>My Blog</title>
+ </head>
+ <body>
+ <h1>Welcome to my Blog!</h1>
+ </body>
+ </html>
+
Then save the file in your application/views/ folder.
Loading a View
@@ -37,10 +44,18 @@
does not need to be specified unless you use something other than .php.
Now, open the controller file you made earlier called blog.php, and
-replace the echo statement with the view loading function:
+replace the echo statement with the view loading function::
-<?php class Blog extends CI_Controller { function index() {
-$this->load->view('blogview'); } } ?>
+ <?php
+ class Blog extends CI_Controller {
+
+ function index()
+ {
+ $this->load->view('blogview');
+ }
+ }
+ ?>
+
If you visit your site using the URL you did earlier you should see your
new view. The URL was similar to this::
@@ -55,8 +70,21 @@
have a header view, a menu view, a content view, and a footer view. That
might look something like this::
- <?php class Page extends CI_Controller { function index() { $data['page_title'] = 'Your title'; $this->load->view('header'); $this->load->view('menu'); $this->load->view('content', $data); $this->load->view('footer'); } } ?>
+ <?php
+ class Page extends CI_Controller {
+
+ function index()
+ {
+ $data['page_title'] = 'Your title';
+ $this->load->view('header');
+ $this->load->view('menu');
+ $this->load->view('content', $data);
+ $this->load->view('footer');
+ }
+
+ }
+ ?>
In the example above, we are using "dynamically added data", which you
will see below.
@@ -77,25 +105,49 @@
an **object** in the second parameter of the view loading function. Here
is an example using an array::
- $data = array( 'title' => 'My Title', 'heading' => 'My Heading', 'message' => 'My Message' ); $this->load->view('blogview', $data);
+ $data = array(
+ 'title' => 'My Title',
+ 'heading' => 'My Heading',
+ 'message' => 'My Message'
+ );
+
+ $this->load->view('blogview', $data);
And here's an example using an object::
- $data = new Someclass(); $this->load->view('blogview', $data);
+ $data = new Someclass();
+ $this->load->view('blogview', $data);
Note: If you use an object, the class variables will be turned into
array elements.
-Let's try it with your controller file. Open it add this code:
+Let's try it with your controller file. Open it add this code::
-<?php class Blog extends CI_Controller { function index() {
-$data['title'] = "My Real Title"; $data['heading'] = "My Real Heading";
-$this->load->view('blogview', $data); } } ?>
+ <?php
+ class Blog extends CI_Controller {
+
+ function index()
+ {
+ $data['title'] = "My Real Title";
+ $data['heading'] = "My Real Heading";
+
+ $this->load->view('blogview', $data);
+ }
+ }
+ ?>
+
Now open your view file and change the text to variables that correspond
-to the array keys in your data:
+to the array keys in your data::
-<html> <head> <title><?php echo $title;?></title> </head> <body>
-<h1><?php echo $heading;?></h1> </body> </html>
+ <html>
+ <head>
+ <title><?php echo $title;?></title>
+ </head>
+ <body>
+ <h1><?php echo $heading;?></h1>
+ </body>
+ </html>
+
Then load the page at the URL you've been using and you should see the
variables replaced.
@@ -107,18 +159,44 @@
generate multiple rows. For example, if you pull data from your database
it will typically be in the form of a multi-dimensional array.
-Here's a simple example. Add this to your controller:
+Here's a simple example. Add this to your controller::
-<?php class Blog extends CI_Controller { function index() {
-$data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands');
-$data['title'] = "My Real Title"; $data['heading'] = "My Real Heading";
-$this->load->view('blogview', $data); } } ?>
-Now open your view file and create a loop:
+ <?php
+ class Blog extends CI_Controller {
-<html> <head> <title><?php echo $title;?></title> </head> <body>
-<h1><?php echo $heading;?></h1> <h3>My Todo List</h3> <ul> <?php foreach
-($todo_list as $item):?> <li><?php echo $item;?></li> <?php
-endforeach;?> </ul> </body> </html>
+ function index()
+ {
+ $data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands');
+
+ $data['title'] = "My Real Title";
+ $data['heading'] = "My Real Heading";
+
+ $this->load->view('blogview', $data);
+ }
+ }
+ ?>
+
+Now open your view file and create a loop::
+
+ <html>
+ <head>
+ <title><?php echo $title;?></title>
+ </head>
+ <body>
+ <h1><?php echo $heading;?></h1>
+
+ <h3>My Todo List</h3>
+
+ <ul>
+ <?php foreach ($todo_list as $item):?>
+
+ <li><?php echo $item;?></li>
+
+ <?php endforeach;?>
+ </ul>
+
+ </body>
+ </html>
.. note:: You'll notice that in the example above we are using PHP's
alternative syntax. If you are not familiar with it you can read about