EllisLab text mark
Advanced Search
1 of 23
1
   
Modular Extensions - HMVC version 5.4
Posted: 02 February 2011 08:31 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Joined: 2008-12-14
544 posts
wiredesignz - 31 January 2011 01:28 AM

With HMVC you need to pass into or set the controller instance for the library before using it.

$this->load->library('form_validation');
$this->form_validation->CI $this;

/* or */

$this->load->library('form_validation', array('CI' => $this)); 

And then process the parameters inside the library constructor.

Hmm, i never had to do that, it just works like normal CI does.
Any thoughts why it is working without doing your suggested trick ?

 
Posted: 06 March 2011 01:51 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2011-03-06
5 posts

Hi wiredesignz!

First of all thanks to codeigniter and all of its friendly users.

Im a big fan of codeigniter and HMVC and I’d been using this for a couple of years.

I have issues regarding codeigniter 2.0 and HMVC 5.4.

I try to use the new feature of codeigniter 2.0 which is the so called package. Using CI 2.0 I autoload the foo_bar folder that contains class called Sample with method name called tae. here is my class located in APPPATH.‘third_party/foo_bar/libraries’:

<?php 
class Sample
{
    
function tae()
    
{
        
echo 'Sample output ===!';    
    
}

my autoload.php looks like:

/*
| -------------------------------------------------------------------
|  Auto-load Packges
| -------------------------------------------------------------------
| Prototype:
|
|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/

$autoload['packages'= array(APPPATH.'third_party/foo_bar'); 

when I try to load the ‘Sample’ class I get some error:

An Error Was Encountered
Unable to load the requested class: sample

Here is my controller:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Welcome extends MX_Controller {

    
function __construct()
    
{
        parent
::__construct();
        
        
$this->load->library('sample');// error occurs here
        
        
$this->sample->tae();
    
}

    
function index()
    
{
        $this
->load->view('welcome_message');
    
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */ 

but when I try to use the add_package_path:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Welcome extends MX_Controller {

    
function __construct()
    
{
        parent
::__construct();
        
        
$this->load->add_package_path(APPPATH.'third_party/foo_bar');
        
$this->load->library('sample');
        
        
$this->sample->tae();
    
}

    
function index()
    
{
        $this
->load->view('welcome_message');
    
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */ 

No errors occured. So the problem is the autoloading of package doesnt working. Some help is appreciated. Im using the latest codeigniter reactor 2.0 and HMVC version 5.4

Thanks and more power! ^.^

 
Posted: 06 March 2011 02:19 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2919 posts

Yes, I haven’t updated Modular Extensions yet for autoloading package paths. I will do this soon.

You could copy the CI_Loader::_ci_autoloader code for autoloading packages and add it to the MX_Loader class if you need this urgently.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 06 March 2011 02:27 AM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2011-03-06
5 posts

@wiredesignz: Thank you so much for a rapid reply!

God Bless! ^.^

 
Posted: 07 March 2011 10:55 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-24
25 posts

I have a question. I’ve read the documentation and the philosophy behind HMVC looks exactly what i’m looking for.
However I’m concerned about the performance impact that it might have on large scale applications…

Does HMVC required much additional memory?
Does it add significant processing time to codeigniter?

 
Posted: 10 March 2011 02:27 PM   [ Ignore ]   [ # 16 ]   [ Rating: 0 ]
Joined: 2011-01-30
6 posts

I already posted this question elsewhere (here), but I thought I’d repost it here in the topic about Modular Extensions - HMVC.

I am having a problem with routing when using Modular Extensions - HMVC (latest version from 2011-03-06) with CodeIgniter 2.0 (not Reactor).

When I use this in application/config/routes.php:

$route['nieuws''news/news/index'

It works as expected.

When I remove that line and place it in application/modules/news/config/routes.php, the browser just sends me to the default controller.

Can anybody assist in this problem? Thanks in advance!

 
Posted: 10 March 2011 04:55 PM   [ Ignore ]   [ # 17 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2919 posts

The “news” module does not require it’s own name to be specified in modules/news/config/routes.php

$route['nieuws''news/index'
 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 11 March 2011 06:28 AM   [ Ignore ]   [ # 18 ]   [ Rating: 0 ]
Joined: 2011-01-30
6 posts

Unfortunately that does not make any difference. Could there be any other reason why the routing is not working properly for me?

Thanks in advance!

 
Posted: 24 March 2011 06:15 PM   [ Ignore ]   [ # 19 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-12
67 posts

Hi,

This issue might be related to HMVC

I have an ajax form in a module controller

after realizing that form validation was not working I added $this->load->library(‘form_validation’, array(‘CI’ => $this));  to it
and when I submitted my ajax form I got this error

ErrorException [ Fatal Error ]Cannot use object of type Admin as array
SYSDIR/var/www/vhosts/churchbackend.com/_sys/libraries/Form_validation.php [ 90 ] 

my controller is

class Admin extends Admin_Controller {

public $data=array();

    public function 
__construct()
       
{
            parent
::__construct();
            
// Your own constructor code
       
}

       
function roles($user_id=NULL)
    
{
        
               $this
->load->library('form_validation', array('CI' => $this)); 
                if (
$this->form_validation->run() == FALSE)
        
{
                       
....show form
                }else{
                    
echo "submitted";
               
}
  } 

my Admin_controller is

class Admin_Controller extends MX_Controller {
function __construct()
       
{
            parent
::__construct();
            
            ... 
load stuff        
    
       } 
 
Posted: 26 March 2011 12:05 AM   [ Ignore ]   [ # 20 ]   [ Rating: 0 ]
Joined: 2009-12-08
7 posts

Hello,

I’ve found a bug with languague autoloader. Sorry but i don’t have the details here, but will be nice if you take a look on it. I just remember that have a wrong param on calling the CI::lang->language(), i’ve fixed the param but still not working.

Congratulations, you are doing a great work.

Regards

 
Posted: 26 March 2011 03:55 AM   [ Ignore ]   [ # 21 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2919 posts
DBPolito - 26 March 2011 04:05 AM

Hello,

I’ve found a bug with languague autoloader. Sorry but i don’t have the details here, but will be nice if you take a look on it. I just remember that have a wrong param on calling the CI::lang->language(), i’ve fixed the param but still not working.

...

There is no language method in the CI_Lang class.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 28 March 2011 12:30 AM   [ Ignore ]   [ # 22 ]   [ Rating: 0 ]
Joined: 2010-10-31
6 posts

Sorry if this is a case of me needing to read more.. but:

Trying to autoload[‘language’] = array(‘sa’);

ends up with the error message: Unable to load the requested language file: language/english/Array_lang.php

Autoloaded helpers and libraries are fine though.

Changing the controller from MY_ to CI_ makes it work..


edit: Made a “MY_controller extends MX controller” with $this->lang-load() in its __construct() and seems to work fine.

In the controller I’m using “home extends MY_controller” I can get a lang->line() out of it.

 
Posted: 28 March 2011 02:59 AM   [ Ignore ]   [ # 23 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2919 posts

@RGM_, Autoload language is working fine here.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 28 March 2011 10:57 AM   [ Ignore ]   [ # 24 ]   [ Rating: 0 ]
Joined: 2009-12-08
7 posts

I think this problem happening only at Reactor Version.

 
Posted: 28 March 2011 04:41 PM   [ Ignore ]   [ # 25 ]   [ Rating: 0 ]
Joined: 2010-10-31
6 posts

Updated to 2.0.1 from codeigniter.com it still comes up with array.

Using wrong version?

 
1 of 23
1