EllisLab text mark
Advanced Search
     
Global Includes with HMVC
Posted: 11 November 2012 07:40 PM   [ Ignore ]
Joined: 2011-11-01
115 posts

I am using HMVC (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/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

<?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?

 
Posted: 11 November 2012 08:16 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

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.

 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess

 
Posted: 11 November 2012 09:25 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-11-01
115 posts

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.

 
Posted: 01 December 2012 08:27 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2012-02-24
53 posts

I have a similar problem after installing HMVC. I’m loading header file from global views and it stops at this part:

<?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
*/