Simple CodeIgniter Templating

/ Published in: PHP
Save to your folder(s)

Basically, a simple way to use a templating system in
CodeIgniter. In your data array, add a view as the value for content. Pass that to the view, then print the $content variable in the view.

Copy this code and paste it in your HTML
  1. //In the controller:
  3. public function index() {
  4. $this->data['content'] = 'your-views-name';
  5. $this->load->view('your-templates-name', $this->data);
  6. }
  8. //In the view:
  10. <?php $this->load->view($content); ?>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.