Welcome Guest, Not a member yet? Register   Sign In
Global Includes with HMVC
#1

[eluser]RMinor[/eluser]
I am using HMVC (https://bitbucket.org/wiredesignz/codeig.../wiki/Home) with CI version 2.1.3. I am stuck on loading views such as a menu, sidebar, or footer into my views for each module. Currently I am using
Code:
<?php $this->load->view('menu_view'); ?>
to try and load a view in the /application/views/ folder into the index view located in /application/modules/index/views/index_view.php. Obviously this is throwing an error. I am not sure exactly how to do this. Can anybody help me out with this?

This is my first HMVC project. Currently I made a separate module for each page (index module, about module, contact module, etc.) each with controllers models, and views. Is this the proper way to do this?
#2

[eluser]PhilTem[/eluser]
This is the proper way of modularizing your project (for when it's the first time that you're using HMVC, but you will get to know more about how to do it in a better way once you're advancing in (H)MVC)

Regarding your problem: I'm not quire sure why you're getting an error because HMVC does actually look for you view first in the module's view folder and then in the global view folder. Only if both folders won't contain the file it will not be displayed. If however you're getting an error, I guess than it cannot find the file probably due to a typo Wink

You may also want to have a look at the MX_Loader::view() method and do some debugging with it to see which folders it loops through and if the arguments passed are correct.
#3

[eluser]RMinor[/eluser]
Thank you for the response. I found the problem and it was incredibly stupid of me, but I was calling the "menu_view" when it was named "menu.php" in the /application/views/ folder. Sorry for such a dumb mistake. I am sure there will be more questions as I dig in deeper with this HMVC stuff.
#4

[eluser]Altazar[/eluser]
I have a similar problem after installing HMVC. I'm loading header file from global views and it stops at this part:
Code:
<?php
$path = 'https://mywebsite.com/images/flags/';
echo anchor($this->lang->switch_uri('en'), img($path.'/en.png'));
echo anchor($this->lang->switch_uri('de'), img($path.'/de.png'));
echo anchor($this->lang->switch_uri('fr'), img($path.'/fr.png'));
?>
I used the same code before (in MVC) and it worked fine.
I tried loading URL helper from the same module's controller, but it didn't help.

Update - Problem solved.
My version of i18n was without this comment:
/*
in case you use it with the HMVC modular extension
uncomment this and remove the other lines
load the MX_Loader class
*/




Theme © iAndrew 2016 - Forum software by © MyBB