Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes.</p> <p>Create a file called <code>template.php</code> in your <code>views</code> folder.</p> <p>The contents of <code>template.php</code>:</p> <pre><code>$this-&gt;load-&gt;view('templates/header'); $this-&gt;load-&gt;view($v); $this-&gt;load-&gt;view('templates/footer'); </code></pre> <p>Then from your controller you can do something like:</p> <pre><code>$d['v'] = 'body'; $this-&gt;load-&gt;view('template', $d); </code></pre> <hr> <p>This is actually a very simplistic version of how I personally load all of my views. If you take this idea to the extreme, you can make some interesting modular layouts:</p> <p>Consider if you create a view called <code>init.php</code> that contains the single line:</p> <pre><code>$this-&gt;load-&gt;view('html'); </code></pre> <p>Now create the view <code>html.php</code> with contents:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;? $this-&gt;load-&gt;view('head'); ?&gt; &lt;? $this-&gt;load-&gt;view('body'); ?&gt; &lt;/html&gt; </code></pre> <p>Now create a view <code>head.php</code> with contents:</p> <pre><code>&lt;head&gt; &lt;title&gt;&lt;?= $title;?&gt;&lt;/title&gt; &lt;base href="&lt;?= site_url();?&gt;"&gt; &lt;link rel="shortcut icon" href='favicon.ico'&gt; &lt;script type='text/javascript'&gt;//Put global scripts here...&lt;/script&gt; &lt;!-- ETC ETC... DO A BUNCH OF OTHER &lt;HEAD&gt; STUFF... --&gt; &lt;/head&gt; </code></pre> <p>And a <code>body.php</code> view with contents:</p> <pre><code>&lt;body&gt; &lt;div id="mainWrap"&gt; &lt;? $this-&gt;load-&gt;view('header'); ?&gt; &lt;? //FINALLY LOAD THE VIEW!!! ?&gt; &lt;? $this-&gt;load-&gt;view($v); ?&gt; &lt;? $this-&gt;load-&gt;view('footer'); ?&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>And create <code>header.php</code> and <code>footer.php</code> views as appropriate.</p> <p>Now when you call the init from the controller all the heavy lifting is done and your views will be wrapped inside <code>&lt;html&gt;</code> and <code>&lt;body&gt;</code> tags, your headers and footers will be loaded in.</p> <pre><code>$d['v'] = 'fooview' $this-&gt;load-&gt;view('init', $d); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload