I am using HMVC in my simple project but I don't know how can I call them inside my controller.
Here's my setup
- modules
- common
- controllers
- header
- footer
- views
- header
- footer
- foo
- controllers
- foo
- views
- foo
My header and footer controller:
class Header extends MX_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$data['title'] = "Welcome to HMVC!";
$this->load->view('header', $data);
}
}
class Footer extends MX_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$data['links'] = array('link1', 'link2', 'link3', 'link4', 'link5', 'link6');
$this->load->view('footer', $data);
}
}
My header and footer view is simple like this:
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<div class="container"><!-- main wrapper -->
....
<ul style="list-style: none">
<?php foreach($links as $link) { ?>
<li><?php echo $link; ?></li>
<?php } ?>
</ul>
</div><!-- end of main wrapper -->
</body>
</html>
And in my foo controller I call them like this:
public function __construct() {
parent::__construct();
$this->load->model('M_Foo');
}
public function index()
{
$data['test'] = $this->M_Foo->sampleQuery();
Modules::run('common/header', $data);
Modules::run('common/footer', $data);
$this->load->view('foo_message', $data);
}
How can I call them inside my controller? I am really new to HMVC.