Part of the EllisLab Network
This thread is a discussion for the wiki article: Modular Extensions - HMVC
   
8 of 23
8
Modular Extensions - HMVC
Posted: 14 May 2009 09:56 AM   [ Ignore ]   [ # 106 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007
Shrike67 - 13 May 2009 09:54 AM

...

$CI is added as a default class variable to libraries loaded by ME. ($CI =& get_instance() is not required), Simply use $this->CI->whatever() in your library.

any suggestion? thanks

Yes adding the $CI library variable was deprecated in ME 5.2

get_instance() returns the application object in ME5.2 and gives access to all loaded objects libraries and models etc, it does not give access to the controller.

If a library requires access to a controller I suggest you pass the object to it.

 Signature 

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

Profile
 
 
Posted: 14 May 2009 12:10 PM   [ Ignore ]   [ # 107 ]  
Summer Student
Avatar
Total Posts:  12
Joined  03-04-2009

Thank you for replying!

Profile
 
 
Posted: 16 May 2009 06:32 AM   [ Ignore ]   [ # 108 ]  
Summer Student
Avatar
Total Posts:  1
Joined  12-17-2008

help plz with HMVC(5209) to work this view http://code-igniter.ru/wiki/View, with last version of HMVC library load view from application/view and not from modules/my/views/

Profile
 
 
Posted: 16 May 2009 07:00 PM   [ Ignore ]   [ # 109 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

@FatalRabbit, Sorry I am not familiar with the view class shown in that example, but it looks like it is using the ME5.2 application object rather than the module controller to load its views.

 Signature 

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

Profile
 
 
Posted: 27 May 2009 02:21 PM   [ Ignore ]   [ # 110 ]  
Grad Student
Avatar
Rank
Total Posts:  34
Joined  06-26-2007

I have a helper what is use module library to generate data with acl checks.

The module library loads module models if the model is not available.
When i load module, and after with loaded module load this module library, the library not able to load model files.

with example:

In users module i load contents module helper what is load (contents module) pagesmanager library to get the pages menu structure.

I debugging and found this: when i load module and module loading his own models, no problem, but when i load module library, the library try to load model from users module and not from the contents module.

What can i do to solve this?

(this is with 5140, now i update to 5209)

 Signature 

owner of http://www.bdteam.hu

Profile
 
 
Posted: 27 May 2009 06:19 PM   [ Ignore ]   [ # 111 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Load the model from it’s controller first. Then it can be accessed from any library.

 Signature 

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

Profile
 
 
Posted: 01 June 2009 07:46 AM   [ Ignore ]   [ # 112 ]  
Grad Student
Avatar
Rank
Total Posts:  31
Joined  11-28-2008
wiredesignz - 14 May 2009 09:38 AM
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class
MY_Form_validation extends CI_Form_validation
{
    
function run($module = '', $group = '') {        
        
(is_object($module)) AND $this->CI =& $module;
        return
parent::run($group);
    
}    
}
/* End of file MY_Form_validation.php */
/* Location: ./application/libraries/MY_Form_validation.php */

and then add “$this” to your validation run call, which tells form validation on which controller to make callbacks.

if ($this->form_validation->run($this)) {
    
...
}

Note that using this extension you should be able to make callbacks on any object method including those in libraries and models.


Hi Wiredesignz, any other way to use form callbacks without hacking FORM_VALIDATION class??.

Form Validation can’t detect method.

Line 583: system/Form_Validation.php

if (! method_exists($this->CI, $rule))
 Signature 

Hardware: Lo que puedes patear.
Software: Lo que puedes maldecir.

Profile
 
 
Posted: 01 June 2009 07:54 AM   [ Ignore ]   [ # 113 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

That is not a hack, it is a class extension.

Actually yes, a much easier way is to add your own callback methods to the MY_Form_validation extension class directly.

 Signature 

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

Profile
 
 
Posted: 01 June 2009 08:12 AM   [ Ignore ]   [ # 114 ]  
Grad Student
Avatar
Rank
Total Posts:  31
Joined  11-28-2008

Thank’s a lot, (sorry by use word ‘hacking’, it was an expression), Other suggestion why not post ME into a repository (I use for my projects xp-dev.com).

Again, Thank you.

 Signature 

Hardware: Lo que puedes patear.
Software: Lo que puedes maldecir.

Profile
 
 
Posted: 01 June 2009 11:30 AM   [ Ignore ]   [ # 115 ]  
Grad Student
Avatar
Rank
Total Posts:  31
Joined  11-28-2008
FatalRabbit - 16 May 2009 06:32 AM

help plz with HMVC(5209) to work this view http://code-igniter.ru/wiki/View, with last version of HMVC library load view from application/view and not from modules/my/views/

Try loading as file instead a view. but i think the problem is about preceding hierarchy.

 Signature 

Hardware: Lo que puedes patear.
Software: Lo que puedes maldecir.

Profile
 
 
Posted: 24 June 2009 02:55 PM   [ Ignore ]   [ # 116 ]  
Grad Student
Rank
Total Posts:  40
Joined  02-10-2009

Very nice contribution! Thanks.

One question though. Is there any support for a modular config folder?

So I can ex. make a form_validation.php config file for each module.

 Signature 

I’m Luke Skywalker. I’m here to rescue you.

Profile
 
 
Posted: 28 June 2009 08:30 PM   [ Ignore ]   [ # 117 ]  
Lab Technician
RankRankRankRank
Total Posts:  1242
Joined  04-19-2008
painting753 - 28 June 2009 10:48 AM

To call a module controller from within a controller you can use $this->load->module() or modules::load() and PHP5 method chaining is available for any object loaded by ME. ie: $this->load->library(‘validation’)->run().

$autoload[‘class’] has been introduced to allow loading base classes from ‘application/libraries’ without instantiation.

The PHP5 spl_autoload feature allows you to freely extend your controllers, models and libraries from application/libraries base classes without the need to specifically include or require them.

The library loader has also been updated to accommodate some CI 1.7 features: ie Library aliases are accepted in the same fashion as model aliases, and loading config files from the module config directory as library parameters (re: Form_validation.php) have beed added.

Thnks

Unitve

[url=http://#[/url]
Photo to portrait


Arrggh… spammers… copied the post from: http://codeigniter.com/forums/viewthread/92212/#481369

 Signature 

PinoyTech - Web Development Blog

Profile
 
 
Posted: 07 July 2009 08:00 AM   [ Ignore ]   [ # 118 ]  
Grad Student
Rank
Total Posts:  40
Joined  02-10-2009

One question on the structure here..

Right now im doing a blog-module with this HMVC-library.

And with a class like /modules/blog/blog.php

Also for articles like /modules/articles/articles.php


What would be best or normal to implement a admin panel?

1. A seperate admin-module /modules/admin/ which holds blog.php and articles.php
(reached by ex. domain.com/admin/blog)

2. Or a admin.php-class inside each of the modules?
(reachead by ex. domain.com/blog/admin)


Is there any spesific difference?

 Signature 

I’m Luke Skywalker. I’m here to rescue you.

Profile
 
 
Posted: 07 July 2009 09:07 PM   [ Ignore ]   [ # 119 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007
asylmottaket - 07 July 2009 08:00 AM

... Is there any spesific difference?

Probably no difference in performance, but there is an organizational difference.

 Signature 

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

Profile
 
 
Posted: 08 July 2009 04:21 AM   [ Ignore ]   [ # 120 ]  
Lab Assistant
RankRank
Total Posts:  162
Joined  04-18-2008

its a great library for generating MVCs modulewise. But is it possible to generate folder inside folder and putting MVC files inside it? Because I want to modularise admin side too. So by putting the MVC files inside admin/module/moduleName makes it unaccessible. So is there anyway to make it accessible? Please help me. Thanks in advance.

 Signature 

Computerzworld  ╠►  Explore the world of computers.

Profile
 
 
   
8 of 23
8
 
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: 120025 Total Logged-in Users: 38
Total Topics: 126159 Total Anonymous Users: 4
Total Replies: 663605 Total Guests: 361
Total Posts: 789764    
Members ( View Memberlist )