Dynamically Load Pages in Code Igniter using a single page Container. Similar to Django template blocks.
-------------------------------------------------------------
controller: user.php
-------------------------------------------------------------
class User extends Base {
public $data = array();
public function login()
{
$this->data['title'] = 'Login';
$this->data['page'] = 'login';
$this->load->view('user/container', $this->data);
}
}
-------------------------------------------------------------
view: user/container.php
-------------------------------------------------------------
<!doctype html>
<html>
<head>
<?php
$this->load->view('user/inc/meta');
?>
</head>
<body>
<?php
$this->load->view('user/inc/header');
$this->load->view('user/section/' . $page);
$this->load->view('user/inc/footer');
?>
</body>
</html>
-------------------------------------------------------------
View Folder Structure
-------------------------------------------------------------
views/
user/
inc/
header.php
footer.php
meta.php
section/
login.php
register.php
other.php
container.php