Reputation: 731
I'm using the HMVC modular separation for my Codeigniter application and trying to figure out how I can attempt this with my template I have set up. There could possibly be a better way to handle this and I'm not sure of it but if anyone can suggest one I'd be all ears. This is my current file system.
Inside each module controller exists a variable called $view_file. This is the variable this is passed to the body content view page and tells it which view file to display inside my content wrapper in my control panel.
I have also included my code for the body content view which contains an if statement to find out
/application
/modules
/dashboard
/controllers
dashboard.php
/views
dashboard_view.php
/views
index_view.php
components/
body_content_view.php
<!--Body content-->
<div id="content" class="clearfix">
<div class="contentwrapper"><!--Content wrapper-->
<?php
if ($this->functions_model->null_check($view_file) === TRUE)
{
$this->load->view('components/body_unknown_view');
}
else
{
if (file_exists($view_file))
{
$this->load->view($view_file);
}
else
{
$this->load->view('components/body_unknown_view');
}
}
?>
</div><!-- End contentwrapper -->
</div><!-- End #content -->
Upvotes: 0
Views: 87
Reputation: 1108
I can't judge the choice on the framework you're using, but, if you really want to use the HMVC pattern, why should you stick with CI?
Don't get me wrong, it's a nice ready to code framework, and probably this is the reason why you picked it, but it's a pain in the bottom when it comes to work with things that come out of it's scope.
Why don't you use other frameworks that support this natively, like Symfony or Laravel??
Anyway, if you still want to stick with CI, have a thourough read at this article
Upvotes: 2