diff options
author | philsturgeon <devnull@localhost> | 2011-06-15 17:00:03 +0200 |
---|---|---|
committer | philsturgeon <devnull@localhost> | 2011-06-15 17:00:03 +0200 |
commit | 0fe54dbaf89a8337d27b9203f74891cf1a799715 (patch) | |
tree | ce168b3c24788e5a4a31e0cc65b64f54e25ee8a2 /user_guide/general/views.html | |
parent | 3a43c7adae7737d68a0eeca663cc2dd3fc5b0cf3 (diff) | |
parent | 3ef65bd7491f847fecdab1acc9687f0e90eee09b (diff) |
Merged Alex Bilbies MSSQL changes.
Diffstat (limited to 'user_guide/general/views.html')
-rw-r--r-- | user_guide/general/views.html | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/user_guide/general/views.html b/user_guide/general/views.html index 746f7b846..ece746592 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.0</h1></td> +<td><h1>CodeIgniter User Guide Version 2.0.2</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->load->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->load->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><?php<br /> <br /> class Page extends CI_Controller {<br /><br /> function index()<br /> {<br /> - $data['page_title'] = 'Your title';<br /> + $data['page_title'] = 'Your title';<br /> $this->load->view('header');<br /> $this->load->view('menu');<br /> $this->load->view('content', $data);<br /> @@ -132,8 +132,8 @@ class Page extends CI_Controller {<br /><br /> ?></code></p> <p>In the example above, we are using "dynamically added data", 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"> <?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 { </body> </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> |