Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a lot of ways to do this. </p> <p>1) Templating: This is my preference for most cases (because my templates are complex), I render my view into a variable using something like:</p> <pre><code>$content = $this-&gt;load-&gt;view('myview', $page_data, true); </code></pre> <p>Then I load it into the template parser (fyi you could load it into another view too) like this: </p> <pre><code>$this-&gt;load-&gt;library('parser'); $data = array( 'page_title' =&gt; 'My Page Title', 'page_content' =&gt; $content, 'side_bar' =&gt; side_bar(), // function which generates your side bar 'right_col' =&gt; right_col() // function which generates your right column ); $this-&gt;parser-&gt;parse('my_template', $data); </code></pre> <p>Then your template is like: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;{page_title}&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt;{side_bar}&lt;/div&gt; &lt;div&gt;{page_content}&lt;/div&gt; &lt;div&gt;{right_col}&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>2) Load another view in your view: (assumes you menu is a view not a controller) Something like this: </p> <pre><code>&lt;?php $this-&gt;load-&gt;view('menu_view'); ?&gt; </code></pre> <p>3) PHP Includes: exactly how you would do it in plain PHP (just include a url which points to a controller which returns a menu), Something like this: </p> <pre><code>&lt;?php include("/common/sidebar"); ?&gt; </code></pre> <p>Codeigniter will render that page and then include it.</p> <p>4) AJAX.. i use this if the content in the "template" content is less important, like banners, suggested related item lists and such.</p>
 

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