EllisLab text mark
Advanced Search
3 of 23
3
   
Modular Extensions - HMVC version 5.4
Posted: 06 April 2011 06:47 AM   [ Ignore ]   [ # 31 ]   [ Rating: 0 ]
Joined: 2010-12-23
13 posts

hi `m new to hmvc pattern.. could u guide me how to integrate it with CI2.0

 
Posted: 06 April 2011 07:22 AM   [ Ignore ]   [ # 32 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

Did you read the article on HMVC in the WIKI? That explains how to set it up and use it.

HMVC

InsiteFX

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

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

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 06 April 2011 07:34 AM   [ Ignore ]   [ # 33 ]   [ Rating: 0 ]
Joined: 2010-12-23
13 posts

@InsiteFX,
thnx for ur reply grin
actually i was converting my application to hmvc. In my application i had a small tweak in MY_router.php . it made me to stumble upon the hmvc installation. now i altered my old my_router.php compatible with HMVC extension. now everything works like charm. Thnx for ur assist grin

 
Posted: 06 April 2011 09:05 AM   [ Ignore ]   [ # 34 ]   [ Rating: 0 ]
Avatar
Joined: 2008-08-19
340 posts

@wiredesignz: Yeah, I really wanted to stay away from that. I don’t want to have to add manual routing for every controller each time.

I ended up going through the code and adding a quick fix that seems to be working very well. The only issue is that when you have an update, I’ll have to modify the code again. Here’s what I did.

In application/third_party/MX/Modules.php on roughly line 92, in the load method, I changed to

list($class) = CI::$APP->router->locate($segmentstrue); 

In application/third_party/MX/Router.php on roughly line 63, the locate method, I changed to

public function locate($segments$get_module=false

Then still in that file, on roughly line 79, I changed to

list($module$directory$controller) = array_pad($segments3NULL);
        
if(
$get_module !== false){
            
    
foreach (Modules::$locations as $location => $offset

And added the corresponding close bracket on roughly line 114, right after the foreach closes.

And finally, in application/core/MY_Router.php on roughly lines 32 and 33 I changed to

public function locate($segments$get_module=false){
    
if($located parent::locate($segments$get_module)) return $located

And I believe that’s it. The only other thing I’d like to do is make it a config option so that I can turn the feature on an off for different projects, but I’ll worry about that later.

 
Posted: 20 April 2011 05:59 PM   [ Ignore ]   [ # 35 ]   [ Rating: 0 ]
Joined: 2010-01-28
40 posts

Is it possible to extend the lang library?  I tried dropping application/libraries/MY_Lang.php with:  class MY_Lang extends MX_Lang {... and it did not work.  I was following the instructions on the ME site “All MY_ extension libraries should include (require) their equivalent MX library file and extend their equivalent MX_ class”. 

Looking through the ME code it looks like it never looks for a MY_Lang file, how can I have it search for this first?  Can any MX libraries be extended?

 
Posted: 20 April 2011 06:47 PM   [ Ignore ]   [ # 36 ]   [ Rating: 0 ]
Avatar
Joined: 2011-01-31
384 posts

drop it in core for ci2.

 Signature 

NetID

 
Posted: 20 April 2011 06:51 PM   [ Ignore ]   [ # 37 ]   [ Rating: 0 ]
Joined: 2010-01-28
40 posts

Also, why when I make a controller that is extended from MX_Controller it will auto-load items in my autoload config but when I extend from CI_Controller it will not?

I am refering to just application/config/autoload.php

 
Posted: 20 April 2011 06:52 PM   [ Ignore ]   [ # 38 ]   [ Rating: 0 ]
Joined: 2010-01-28
40 posts

osci,

when I do that I get the error:

Fatal error: Class ‘CI_Controller’ not found in D:\Development\intranet_new\system\core\CodeIgniter.php on line 231

 
Posted: 21 April 2011 03:34 AM   [ Ignore ]   [ # 39 ]   [ Rating: 0 ]
Joined: 2010-12-23
13 posts

@wilso417 ,
did u dropped ur MY_lang file inside the “application\core”

 
Posted: 21 April 2011 01:14 PM   [ Ignore ]   [ # 40 ]   [ Rating: 0 ]
Joined: 2010-01-28
40 posts

Yes, I tried MY_Lang.php in application/core which returned the controller error.  I also tried it in application/libraries and it just did not pick up.  After digging around the HMVC I noticed it was not being checked for at all, so I put in some checks for it.  In base.php I did a check to include the file (at the top):

if (file_exists(APPPATH . ‘libraries/MY_Lang.php’)) require_once APPPATH . ‘libraries/MY_Lang.php’;
else require_once dirname(__FILE__).’/Lang.php’;

Next I checked to initialize in the CI constructor:

if (!is_a($this->lang, ‘MY_Lang’) && !is_a($this->lang, ‘MX_Lang’)) $this->lang = (class_exists(‘MY_Lang’, FALSE)) ? new MY_Lang : new MX_Lang;

Not sure if this is the best approach, but this was a workaround I found.  I was just surprised something like this was not built in to HMVC since the wiki says you can still extend libraries.

 
Posted: 21 April 2011 01:20 PM   [ Ignore ]   [ # 41 ]   [ Rating: 0 ]
Joined: 2010-12-23
13 posts

whats the version of CI you use???

 
Posted: 21 April 2011 01:35 PM   [ Ignore ]   [ # 42 ]   [ Rating: 0 ]
Joined: 2010-01-28
40 posts

Newest CI & ME HMVC. Just downloaded and set them up a few days ago

 
Posted: 21 April 2011 01:46 PM   [ Ignore ]   [ # 43 ]   [ Rating: 0 ]
Joined: 2010-12-23
13 posts

did you inherited my_lang like this inside core?

require APPPATH.“third_party/MX/Lang.php”;

class MY_Lang extends MX_Lang {}

 
Posted: 21 April 2011 01:52 PM   [ Ignore ]   [ # 44 ]   [ Rating: 0 ]
Joined: 2010-01-28
40 posts

Yes I did.  In fact, even with my workaround I still have to do that.

 
Posted: 22 April 2011 12:01 AM   [ Ignore ]   [ # 45 ]   [ Rating: 0 ]
Joined: 2010-11-16
30 posts

hi, has every one try the latest code from codeigniter reactor 2011 04 22 ?

A PHP Error was encountered

Severity
Notice

Message
Undefined propertyCI::$_ci_cached_vars

Filename
MX/Loader.php

Line Number
265 
 
3 of 23
3