Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just write little additional library(<code>application/libraries/display_lib.php</code>) for rendering tempates and similar page blocks. Something like this:</p> <pre><code> class Display_Lib{ private $_CI; private $_template_data; public function __construct() { $this-&gt;_CI =&amp; get_instance(); } public function set($key, $value) { $this-&gt;_template_data[$key] = $value; } public function get($key) { return $this-&gt;_template_data[$key]; } public function get_template_data() { return $this-&gt;_template_data; } public function display_page($view, $data = array()) { $this-&gt;set('content', $this-&gt;_CI-&gt;load-&gt;view($view, $data, TRUE)); $this-&gt;_CI-&gt;load-&gt;view('templates/main_template', $this-&gt;get_template_data()); } } </code></pre> <p>Set this library in auto load:</p> <pre><code>$autoload['libraries'] = array('session', 'database', 'display_lib'); </code></pre> <p>And call it in controller:</p> <pre><code>class Main extends CI_Controller{ public function index() { $some_data = array(); $this-&gt;display_lib-&gt;display_page('views/main_view', $some_data); } } </code></pre> <p>Template example:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;base href="&lt;?=base_url();?&gt;"&gt; &lt;meta charset="utf-8"&gt; &lt;link rel="icon" href="&lt;?=site_url('img/favicon.ico')?&gt;" type="image/x-icon"/&gt; &lt;link rel="stylesheet" href="&lt;?=site_url('css/style.css');?&gt;" type="text/css" media="screen, projection"/&gt; &lt;script type="text/javascript" src="&lt;?=site_url('js/jquery-1.10.2.min.js');?&gt;"&gt;&lt;/script&gt; &lt;title&gt;Some page title&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt;&lt;/header&gt; &lt;div class="auth_wrapper"&gt; &lt;div class="content"&gt; &lt;?=$content;?&gt; &lt;/div&gt; &lt;div class="buffer"&gt;&lt;/div&gt; &lt;/div&gt; &lt;footer&gt;&lt;/footer&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And <code>application/views/main_view</code> simple exmaple:</p> <pre><code>&lt;div&gt;Come content will be here&lt;/div&gt; </code></pre> <p>This lib allow to use templates and render views from controllers.</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