Part of the EllisLab Network
This thread is a discussion for the wiki article: Modular Extensions - HMVC
   
2 of 23
2
Modular Extensions - HMVC
Posted: 29 October 2008 06:34 AM   [ Ignore ]   [ # 16 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Actually it does work. Check your installation setup again.

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 29 October 2008 06:41 AM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  349
Joined  05-04-2008

Woops, I did such a stupid thing. Sorry, all is well smile

 Signature 

[ Adam Griffiths - Shropshire Based Web Developer ]
[ The Authentication Library User Guide ]
[ Programmers Voice - PHP and CodeIgniter articles, tutorials and screencasts. ]
[ Follow me on Twitter ]

Profile
 
 
Posted: 29 October 2008 03:30 PM   [ Ignore ]   [ # 18 ]  
Grad Student
Rank
Total Posts:  92
Joined  09-10-2008

There are a few things I wish ME would handle, namely incorporate subclassing of the ME library classes.  I had to change a few things in the load_class function within CI’s system base and change the Controller constructor to create a MY_Loader.  I do like the fact the latest version has only three files, this eliminates reaching into the helper directory at all and provides a makeshift namespace for the static functions.  My second request would be the allowance of a callback to add paths for searching within modules.  It currently searches within ‘Module’/‘Folder’/views/‘Class’ but not ‘Module’/views/‘Folder’/‘Class’.  I know it would get rather complex if you enabled that rule from the start but it would be nice to have a callback or other way to dynamically add locations to search to match your applications unique design.

Overall, I find this library to be extremely useful and use it extensively for the main project I am working on.

Profile
 
 
Posted: 29 October 2008 03:52 PM   [ Ignore ]   [ # 19 ]  
Grad Student
Rank
Total Posts:  92
Joined  09-10-2008

Also, loading ‘Module’/‘Folder’/controllers/‘Class’ appears to be broken.  The folder gets stripped out here:

Modules.php

60    
/* get the module name */
61    list($module) = explode('/', $module);
Profile
 
 
Posted: 29 October 2008 11:48 PM   [ Ignore ]   [ # 20 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

@dcunited08,

Can you explain what you mean by callback, also what is ‘Module’/‘Folder’? and which ME class do you need to extend?

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 30 October 2008 10:24 AM   [ Ignore ]   [ # 21 ]  
Grad Student
Rank
Total Posts:  92
Joined  09-10-2008
wiredesignz - 29 October 2008 11:48 PM

@dcunited08,

Can you explain what you mean by callback, also what is ‘Module’/‘Folder’? and which ME class do you need to extend?

ME supports submodules, I.E. APPPATH/modules/mod_name/sub_mod_name.  The views and models and such load fine, the controllers do not.  That is the ‘Module’/‘Folder’.

The callback I am talking about is in find where all the possible paths are selected.  It would be nice to allow a user-defined function to add to that list.  In my app, I have a mod_name/views/folder/view_name which currently is not supported.  That is fine that it is not supported, I would like to be able to add it to the places to search by defining a function that adds it.

The class I was attempting to extend was the Loader class, the reason is that the load property does not appear to be copied properly to models because the get_instance function returns the called_controller, not the loaded_module.  The end result is loaded_model->load is the instance created by the called_controller so when libraries are loaded they are copied to the other models (if any), not the loaded_model.

definitions:
called_controller = controller called by CI,
loaded_module = controller loaded by load->module(),
loaded_model = model loaded by the loaded_module.

in MY_Modules
static function get_calling_instance($_caller = null)
    
{
        
if($_caller === null)
        
{
            
return get_instance();
        
}else{
            
return self::$registry[$_caller];    
        
}
        
    }

This is then called in the MY_Model:_assign_libraries function and the $_caller is set by a parameter in the constructor.  If there is a better way to do this, I would be great appreciative if you would point it out.  The only other way I could think to do this is by doing a backtrace to see what the calling object was.

Overall, I had it working in the old version because you used the Controller as the load class but I am glad you moved that functionality to a separate Load class.

Profile
 
 
Posted: 30 October 2008 11:09 AM   [ Ignore ]   [ # 22 ]  
Grad Student
Rank
Total Posts:  92
Joined  09-10-2008

Update:

I used debug_backtrace to get a list of calling objects and simple used the last item that is an instance of Controller as the caller.

static function get_calling_instance()
    
{
        $_caller
= null;
        
$arr = debug_backtrace();
        
array_walk($arr, 'MY_Modules::find_calling_class', &$_caller);
        if(
$_caller === null)
        
{
            
return get_instance();
        
}else{
            
return self::$registry[$_caller];    
        
}
        
    }
    
    
static function find_calling_class($var, $unused, &$id)
    
{
        
        
if($var['object'] instanceof Controller && $id == null )
        
{
            $id
= strtolower($var['class']);
            
        
}
        
    }

This keeps me from having to pass the caller variable on to the constructor and allows me to get rid of my customized load->model function.

Profile
 
 
Posted: 31 October 2008 12:35 AM   [ Ignore ]   [ # 23 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

Hi all,
This is great!
Small issue I have just come across tho
I am loading various libraries into a controller I have called as a module. It will not load the user_agent library but will happily load form_validation library.
Anyone seen this before?

cheers,
dan

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 31 October 2008 02:09 AM   [ Ignore ]   [ # 24 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Modular Extensions 5.1.37 is now available on the wiki.

fixed the user_agent library loader bug mentioned above. Thanks ImageSmith wink

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 31 October 2008 02:25 AM   [ Ignore ]   [ # 25 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

all good.
love your work!  wink

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 31 October 2008 06:30 AM   [ Ignore ]   [ # 26 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

@ImageSmith, Thanks.

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 02 November 2008 07:38 PM   [ Ignore ]   [ # 27 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

I am having a bit of strife with running nested modules.
Not sure if I am on the right track but from what documentation I have found and read it should be possible to have nested modules in the format as follows:

modules | admin | controllers | admin.php
modules | admin | modules | gallery | controllers | gallery.php
modules | admin | modules | archive | controllers | archive.php

Am I barking up the wrong tree with this?

cheers,
dan

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 02 November 2008 11:04 PM   [ Ignore ]   [ # 28 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Nested modules are not supported and the paragraph on the wiki which mentioned so, was totally incorrect and is now gone.

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 02 November 2008 11:14 PM   [ Ignore ]   [ # 29 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

no probs,
ta for that

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 09 November 2008 11:10 PM   [ Ignore ]   [ # 30 ]  
Summer Student
Total Posts:  1
Joined  11-09-2008

Hi smile

I’d like to use this module but i need the file structure to be something like this
module/admin/controllers/acontroller.php or module/controllers/admin/acontroller.php
module/controllers/acontroller.php

and to map to these urls
admin/module/acontroller
module/acontroller

The basic idea is to have both the frontend & the admin in the same module and to be able to map to domain/module or domain/admin/module . I want all the admin paths to be under admin in the url but for it all to be self-contained in the module (front & backend).

I read the docs and it seems it’s not possible - i would have to use module/admin/controller for all the controllers - but i want to be really sure. So is it possible or not? smile

update: should be possible with routes such as
$route[‘admin/([a-z]+)/([-a-z]+)/(\d+)’] = “admin/$1/$2/$3.html”;

Profile
 
 
   
2 of 23
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120248 Total Logged-in Users: 43
Total Topics: 126381 Total Anonymous Users: 3
Total Replies: 664671 Total Guests: 394
Total Posts: 791052    
Members ( View Memberlist )