Part of the EllisLab Network
   
2 of 11
2
Modular Extensions - (HMVC) - Version 2.1.8
Posted: 20 February 2008 08:33 AM   [ Ignore ]   [ # 11 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Why bother with helpers, the view can call the modules loader directly. Just put my function inside the Modules class definition.

 Signature 

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

Profile
 
 
Posted: 20 February 2008 08:35 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  12-25-2007
$this->load->library('modules');       //or in autoload.php

This you put in your controller constructor or in config/autoload.php

$this->modules->load('product_list');
<?php echo $this->product_list->render($catcode); ?>

I think you can put the $this->modules->load(‘product_list’) into your view, but instead of using a render() method in your module, you must use its constructor. I don’t want to load the modules from my controllers too. When I load a view, it is up to the view to load the modules it may have.


@wiredesignz: Thank you!

 Signature 

Oh God… Why didn’t you show me CodeIgniter before?

Profile
 
 
Posted: 20 February 2008 08:39 AM   [ Ignore ]   [ # 13 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

I wouldn’t load a module inside a view, and I wouldn’t use a helper, I would add a function to the class as I suggested. Do the whole thing with one line of code in the view.

Using unecessary helpers is just code bloat.

 Signature 

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

Profile
 
 
Posted: 20 February 2008 08:57 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  285
Joined  02-13-2008

@wiredesignz: agree. Please add it to an “official” piece of code.

Profile
 
 
Posted: 20 February 2008 09:22 AM   [ Ignore ]   [ # 15 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Added. Thanks Sam, hope it’s of use. wink

 Signature 

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

Profile
 
 
Posted: 20 February 2008 09:50 AM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  12-25-2007

I wouldn’t load a module inside a view, and I wouldn’t use a helper, I would add a function to the class as I suggested. Do the whole thing with one line of code in the view.

Sorry, I don’t get it… For example, how can I load a module into a <div></div> in my view, with just one line of code, and without loading the module directly from the view? I would like to keep the views and controllers decoupled in respect to the modules. The controller load the view, the view load the modules. If I move a module from one view to another, I don’t want to everytime reflect these changes in the controllers. In this aspect, the modules must be independent from the controllers.

 Signature 

Oh God… Why didn’t you show me CodeIgniter before?

Profile
 
 
Posted: 20 February 2008 10:00 AM   [ Ignore ]   [ # 17 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Edmilson, I have added a new method to load and render any module from your view. You don’t need to load it in a controller unless you need to access it somehow.

<?php $this->modules->render('any_module'); ?>    //your module must contain a render() method.
 Signature 

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

Profile
 
 
Posted: 20 February 2008 11:58 AM   [ Ignore ]   [ # 18 ]  
Lab Assistant
RankRank
Total Posts:  251
Joined  08-05-2007

Is the url still the same?

E.g. http://www.site.com/module/controller/function ?

Is there anyway of making it http://www.site.com/controller/function like normally?

 Signature 

CI Base - CodeIgniter Repository

Profile
 
 
Posted: 20 February 2008 12:04 PM   [ Ignore ]   [ # 19 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  12-25-2007

Edmilson, I have added a new method to load and render any module from your view.

In this case, isn’t the index() function of a controller equivalent to the render() function of a module? What happen if I write an index() function in my module? Will it not be executed by default? Instead of a render() method, I could use index() and/or a constructor, to keep it more close to the controller standard. What do you think?

 Signature 

Oh God… Why didn’t you show me CodeIgniter before?

Profile
 
 
Posted: 20 February 2008 01:51 PM   [ Ignore ]   [ # 20 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007
Kemik - 20 February 2008 11:58 AM

Is the url still the same?

E.g. http://www.site.com/module/controller/function ?

Is there anyway of making it http://www.site.com/controller/function like normally?

Sorry, this modules is not the same as Zach’s Matchbox modules.
This is a HMVC style system where the modules act as psuedo-controllers and can be used to perform a specific MVC process (modular).
They aren’t aware of the routing or uri structure of an application unless you make it so. I have used the _remap() function in my main controller to decide which module to load and run.

@Edmilson: Yes you could use index() as the default method in a module.

 Signature 

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

Profile
 
 
   
2 of 11
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: 120453 Total Logged-in Users: 39
Total Topics: 126533 Total Anonymous Users: 4
Total Replies: 665354 Total Guests: 324
Total Posts: 791887    
Members ( View Memberlist )