summaryrefslogtreecommitdiffstats
path: root/user_guide/general/views.html
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2011-07-02 00:54:49 +0200
committerDerek Jones <derek.jones@ellislab.com>2011-07-02 00:54:49 +0200
commit8f371a4954ec84f9ea80c26e654a4793714f8a07 (patch)
tree912d83e6e2adbe136d892f0a41ea1730dc11206a /user_guide/general/views.html
parent806b82448ddccece1311228519dc1410dacd0971 (diff)
parent4b9c62980599228f070b401c7673dce8085b0c61 (diff)
hand merged remaining unresolved files following the backout of 648b42a75739, which was a NON-trivial whitespace commit
Diffstat (limited to 'user_guide/general/views.html')
-rw-r--r--user_guide/general/views.html28
1 files changed, 14 insertions, 14 deletions
diff --git a/user_guide/general/views.html b/user_guide/general/views.html
index ece746592..ad93f4bc7 100644
--- a/user_guide/general/views.html
+++ b/user_guide/general/views.html
@@ -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>