summaryrefslogtreecommitdiffstats
path: root/user_guide/general/views.html
diff options
context:
space:
mode:
authorGreg Aker <greg@gregaker.net>2011-08-20 18:58:58 +0200
committerGreg Aker <greg@gregaker.net>2011-08-20 18:58:58 +0200
commitabbad9ea53e81c6e3211029711ac5b2ab4f1978d (patch)
tree9a4d5a8587da1dd3a365251afa37be2f835a53c2 /user_guide/general/views.html
parent71644d683d0a15a6f7e04fabd0f51a4200d620b4 (diff)
parentd56be70257696d0bbf2dcc880888d8dc17cba21c (diff)
Merge branch 'develop' into feature/unit-tests
Conflicts: .hgignore
Diffstat (limited to 'user_guide/general/views.html')
-rw-r--r--user_guide/general/views.html30
1 files changed, 15 insertions, 15 deletions
diff --git a/user_guide/general/views.html b/user_guide/general/views.html
index ece746592..a2273f862 100644
--- a/user_guide/general/views.html
+++ b/user_guide/general/views.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td>
+<td><h1>CodeIgniter User Guide Version 2.0.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
@@ -61,7 +61,7 @@ Views
In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type
of hierarchy.</p>
-<p>Views are never called directly, they must be loaded by a <a href="controllers.html">controller</a>. Remember that in an MVC framework, the Controller acts as the
+<p>Views are never called directly, they must be loaded by a <a href="controllers.html">controller</a>. Remember that in an MVC framework, the Controller acts as the
traffic cop, so it is responsible for fetching a particular view. If you have not read the <a href="controllers.html">Controllers</a> page
you should do so before continuing.</p>
@@ -90,7 +90,7 @@ you should do so before continuing.</p>
<code>$this->load->view('<var>name</var>');</code>
-<p>Where <var>name</var> is the name of your view file. Note: The .php file extension does not need to be specified unless you use something other than <kbd>.php</kbd>.</p>
+<p>Where <var>name</var> is the name of your view file. Note: The .php file extension does not need to be specified unless you use something other than <kbd>.php</kbd>.</p>
<p>Now, open the controller file you made earlier called <dfn>blog.php</dfn>, and replace the echo statement with the view loading function:</p>
@@ -109,19 +109,19 @@ class Blog extends CI_Controller {
</textarea>
-<p>If you visit your site using the URL you did earlier you should see your new view. The URL was similar to this:</p>
+<p>If you visit your site using the URL you did earlier you should see your new view. The URL was similar to this:</p>
<code>example.com/index.php/<var>blog</var>/</code>
<h2>Loading multiple views</h2>
-<p>CodeIgniter will intelligently handle multiple calls to $this-&gt;load-&gt;view from within a controller. If more than one call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view. That might look something like this:</p>
+<p>CodeIgniter will intelligently handle multiple calls to $this-&gt;load-&gt;view from within a controller. If more than one call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view. That might look something like this:</p>
<p><code>&lt;?php<br />
<br />
class Page extends CI_Controller {<br /><br />
&nbsp;&nbsp;&nbsp;function index()<br />
&nbsp;&nbsp;&nbsp;{<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$data['page_title'] = 'Your title';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$data['page_title'] = 'Your title';<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('header');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('menu');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('content', $data);<br />
@@ -132,8 +132,8 @@ class Page extends CI_Controller {<br /><br />
?&gt;</code></p>
<p>In the example above, we are using &quot;dynamically added data&quot;, which you will see below.</p>
<h2>Storing Views within Sub-folders</h2>
-<p>Your view files can also be stored within sub-folders if you prefer that type of organization. When doing so you will need
-to include the folder name loading the view. Example:</p>
+<p>Your view files can also be stored within sub-folders if you prefer that type of organization. When doing so you will need
+to include the folder name loading the view. Example:</p>
<code>$this->load->view('<kbd>folder_name</kbd>/<var>file_name</var>');</code>
@@ -159,7 +159,7 @@ $this->load->view('blogview', <var>$data</var>);</code>
<p>Note: If you use an object, the class variables will be turned into array elements.</p>
-<p>Let's try it with your controller file. Open it add this code:</p>
+<p>Let's try it with your controller file. Open it add this code:</p>
<textarea class="textarea" style="width:100%" cols="50" rows="14">
&lt;?php
@@ -195,8 +195,8 @@ class Blog extends CI_Controller {
<h2>Creating Loops</h2>
-<p>The data array you pass to your view files is not limited to simple variables. You can
-pass multi dimensional arrays, which can be looped to generate multiple rows. For example, if you
+<p>The data array you pass to your view files is not limited to simple variables. You can
+pass multi dimensional arrays, which can be looped to generate multiple rows. For example, if you
pull data from your database it will typically be in the form of a multi-dimensional array.</p>
<p>Here's a simple example. Add this to your controller:</p>
@@ -243,15 +243,15 @@ class Blog extends CI_Controller {
&lt;/body>
&lt;/html>
</textarea>
-<p><strong>Note:</strong> You'll notice that in the example above we are using PHP's alternative syntax. If you
+<p><strong>Note:</strong> 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 it <a href="alternative_php.html">here</a>.</p>
<h2>Returning views as data</h2>
<p>There is a third <strong>optional</strong> parameter lets you change the behavior of the function so that it returns data as a string
-rather than sending it to your browser. This can be useful if you want to process the data in some way. If you
-set the parameter to <kbd>true</kbd> (boolean) it will return data. The default behavior is <kbd>false</kbd>, which sends it
-to your browser. Remember to assign it to a variable if you want the data returned:</p>
+rather than sending it to your browser. This can be useful if you want to process the data in some way. If you
+set the parameter to <kbd>true</kbd> (boolean) it will return data. The default behavior is <kbd>false</kbd>, which sends it
+to your browser. Remember to assign it to a variable if you want the data returned:</p>
<code>$string = $this->load->view('<var>myfile</var>', '', <kbd>true</kbd>);</code>