Part of the EllisLab Network
This thread is a discussion for the wiki article: Modular Extensions - HMVC
   
3 of 23
3
Modular Extensions - HMVC
Posted: 10 November 2008 12:33 AM   [ Ignore ]   [ # 31 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

routes would seem to me to be the way to go.
you will also need to run an auth system on a per method basis in your module controllers so as to secure the admin methods

edit:
I would use routes like this:

$route[‘admin/([a-z]+)/([-a-z]+)/(\d+)’] = $1/admin/$2/$3”;

and channel all admin traffic for a module through a method called “admin” in that module controller.
...but that’s just me

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 14 November 2008 01:31 AM   [ Ignore ]   [ # 32 ]  
Grad Student
Avatar
Rank
Total Posts:  34
Joined  06-26-2007

wiredesignz!

How can i extend loader? With MY_Loader?
I want to make shared classes in seperate dir (under BASEPATH) and later load my classes from any application.

I try MY_Loader extends CI_Loader and add myclass function but i can’t call from controller with $this->load->myclass(‘classname’).

Did I excuse something possibly?

(sorry my bad english…)

 Signature 

owner of http://www.bdteam.hu

Profile
 
 
Posted: 14 November 2008 03:39 AM   [ Ignore ]   [ # 33 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Try this thread. http://codeigniter.com/forums/viewreply/485042/

 Signature 

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

Profile
 
 
Posted: 14 November 2008 03:58 AM   [ Ignore ]   [ # 34 ]  
Grad Student
Avatar
Rank
Total Posts:  34
Joined  06-26-2007

Mega thanx   cool smile

 Signature 

owner of http://www.bdteam.hu

Profile
 
 
Posted: 15 November 2008 06:18 AM   [ Ignore ]   [ # 35 ]  
Summer Student
Total Posts:  28
Joined  09-16-2007

I’m playing around with ME, trying to get a feel for it and how to best integrate it. I am finding that I need to think quite differently about how I structure things when using ME. I’m a hobbyist with CI experience, but a complete noob to ME.

One of the things I am trying to understand is the best way to use ME for my projects: should I have a set of application MVCs that calls upon functional modules to do the heavy lifting (this is, using modules like “uber-libraries”), or should a project be made up ALL from modules, with one module being the main application manager.

Currently, I am trying out the former - uber-libraries - and it is working pretty well.

One issue I have with this approach, is how to get a controller in a module to invoke a method in a application controller. For example, I have a module, “User”, that does all the login/logout stuff (using Redux Auth). When logging in, the User module is invoked by an application/view (module::run) loaded by a controller in application/controller. The User module loads a view to display a login form. The form is submitted to the module for validation and authentication (all User logic is in the User controller) and if login successful, redirects to the homepage, or if unsuccessful redirects to the application/controller to display the login page again (with some flashdata feedback).

However, if there is a form validation error, I’m not sure what I should do. I can reload the login form, but since the validation is done in the module, loading the modules login partial view replaces the whole page. So this isn’t a solution. On the other hand, I could try to reload the whole page by invoking the application/controller from the module controller doing the validation, but I can’t seem to do that (also, not sure this will retain and display the login form’s validation errors - I’m hoping it will).

I tried

$this->user->login()
and
$this->CI->user->login()

but both returned non-object errors.

Profile
 
 
Posted: 16 November 2008 05:49 PM   [ Ignore ]   [ # 36 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

onblur,
are you passing any data to the login form partial?
more to the point, do you have ability to pass validation data to the partial?

have you tried validation class helpers in the partial (v1.7 onward)?

the should be some method of getting data into your partial (even session or flashdata in a pinch).

cheers,
dan

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 16 November 2008 06:10 PM   [ Ignore ]   [ # 37 ]  
Summer Student
Total Posts:  28
Joined  09-16-2007

Thanks Dan.

No data passed to the partial.

Actually, I’ve reworked things a bit. The partial contains the login form. Originally, I had the form submit directly to the module controller to process, which depending on the outcome (success/fail), may have needed to invoke a method in an application/controller.

I have now decided to submit the form to the application/controller and pass off to the module controller as required. This is working well with form valiation (1.7) flashdata and the Template Library library.

Though, would be nice to know if a module controller can call a method in a application/controller.

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

Though, would be nice to know if a module controller can call a method in a application/controller.

I’m pretty sure this is possible. Try to load the application/controller as a module

$this->load->module('some_module');

where the controller name is the name used in the load call, then access via

$this->some_module->some_method()

I’m fairly confident that I had something like this going before I went down the all module track

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 22 November 2008 09:20 PM   [ Ignore ]   [ # 39 ]  
Summer Student
Total Posts:  4
Joined  02-02-2007

Not sure this was mentioned already, but I recently upgraded to the new version of CI, and the profiler is now broken. I think one of the new things added to the profiler was controller info (class & method), and this seems like it’s breaking. I just commented out the line that calls this method when running the profiler, and this is fine, but I’d rather HMVC somehow deal with this…

Anyways, just a heads up, and great extension btw.

Profile
 
 
Posted: 23 November 2008 05:08 PM   [ Ignore ]   [ # 40 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

Hi vsanghvi,
What version of CI are you using?
I am using the HMVC system with ci 1.7.0 and it is working fine.

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 07 December 2008 11:08 AM   [ Ignore ]   [ # 41 ]  
Grad Student
Avatar
Rank
Total Posts:  55
Joined  03-19-2008

I wonder if anyone can help me with this one:

As i remember from endles ME/HMVC threads having multiple controllers in one module is possible.
Is this correct with latest HMVC?

I have a module “Dashboard” with to controllers that are:

/modules/dashboard/controllers/dashboard.php (frontend)
/modules/dashboard/controllers/backend.php (administration)

I then call these controllers as stated in the wiki like this: modules::run(“module/controller/method”);

But that works only with dashboard.php controller.

So this works:

modules::run(“dashboard”);
modules::run(“dashboard/dashboard/index”);

And same call does not:
modules::run(“dashboard/backend/index”);


UPDATE:

I figured out the error - it was a name collision between module controller name and application controller.
For example:

/application/controllers/backend.php - Major backend controller - runs all the modules in “backend mode”.
In this case you can not name your module controller “backend”. You may use “module_backend” name instead.

Profile
 
 
Posted: 14 December 2008 08:31 AM   [ Ignore ]   [ # 42 ]  
Lab Assistant
RankRank
Total Posts:  182
Joined  08-07-2007

I have finally managed to convince my employers and colleagues to start using CI for all our future developements. Although I have used CI for smaller projects as a standard we plan to use HMVC for its portability.

There are 2 questions I have that I couldn’t find on the forum and was hoping for some help please ?

1. What Auth library is best to use with HMVC, I tried to use Freaky Auth with matchbox before and ran into some problems. But I understand HMVC layout is different.

2. How should the folders be structured and linked for an admin area and front end ? Will there be seperate admin and front end controllers or should there be separate modules ?

Any answers or links to help is appreciated .

 Signature 

http://www.twitter.com/gunkdesign

Profile
 
 
Posted: 15 December 2008 09:32 AM   [ Ignore ]   [ # 43 ]  
Grad Student
Avatar
Rank
Total Posts:  55
Joined  03-19-2008

I experience some problems with new 1.7.0 Validation Class Helper.
When i re-populate the form with submitted data it doesn’t actually show up if the field has no rules attached in the controller (with set_rules() function). It may have any rule attached - like required trim or just anything. It just has to be there in the rules list.

This seems strange. Am I the only one who has this problem?
Anyway i might post back hrere if i discover more on the topic.

UPDATE:

After some testing i discovered that this seems to be not the HMVC issue but CI issue. So i better direct this post to CI forums.
Cheers!

Profile
 
 
Posted: 15 December 2008 05:43 PM   [ Ignore ]   [ # 44 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  05-10-2007

Opel,
I created my own Auth module for use with HMVC.
Also I am using a different controller for front and back of site. Modules, however, can be common to both so I am carrying out front and back auth, etc on a per method basis in the modules.

Hope this makes sense.

 Signature 

Cairns Web Designer
Cairns Web Design

Profile
 
 
Posted: 15 December 2008 06:01 PM   [ Ignore ]   [ # 45 ]  
Lab Assistant
RankRank
Total Posts:  182
Joined  08-07-2007

thanks for the response ImageSmith could you please explain how your module and url’s look ?

Is it :

module
—admin
—front

then index.php/module/admin/add etc ?

do you have to change anything in your routers ?

 Signature 

http://www.twitter.com/gunkdesign

Profile
 
 
   
3 of 23
3
 
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: 120541 Total Logged-in Users: 29
Total Topics: 126599 Total Anonymous Users: 2
Total Replies: 665563 Total Guests: 344
Total Posts: 792162    
Members ( View Memberlist )