summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-19 00:19:41 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-19 00:19:41 +0100
commit270c0aa7ba550cafb65629be3c38b27ea9012f67 (patch)
tree4168df99f84914cf582edfce1458fb927f11233e
parent66f0724c3cdd2ea1de313bf407d40c38faf95b1d (diff)
documentation for multiple views
-rw-r--r--user_guide/general/views.html19
1 files changed, 18 insertions, 1 deletions
diff --git a/user_guide/general/views.html b/user_guide/general/views.html
index 83be4d4f0..5ad9fc5c0 100644
--- a/user_guide/general/views.html
+++ b/user_guide/general/views.html
@@ -113,8 +113,25 @@ class Blog extends Controller {
<code>www.your-site.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 then 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 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;$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 />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;view('footer');<br />
+&nbsp;&nbsp;&nbsp;}<br />
+<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>