Part of the EllisLab Network
This thread is a discussion for the wiki article: Modular Extensions - HMVC
   
35 of 36
35
Modular Extensions - HMVC
Posted: 01 January 2012 05:07 PM   [ Ignore ]   [ # 511 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

@huy, Do not edit the code. Move the view files to the modules/auth/views directory.

 Signature 

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

Profile
 
 
Posted: 02 January 2012 01:02 AM   [ Ignore ]   [ # 512 ]  
Summer Student
Total Posts:  14
Joined  10-06-2011
wiredesignz - 01 January 2012 05:07 PM

@huy, Do not edit the code. Move the view files to the modules/auth/views directory.

I cant do it :( Can you help me install Tank Auth with HMVC in Codeigniter 2.1.0? :( thankyou so much !!!

Profile
 
 
Posted: 02 January 2012 04:35 AM   [ Ignore ]   [ # 513 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

@huy,  The only changes that are required to make Tank Auth work as a module is to move the application files into a new modules/auth directory and move the views/auth directory files inside the auth module. e.g. move them to modules/auth/views.

There may be other problems using Tank Auth with CI 2.1.0 but these are not related to Modular Extensions HMVC.

 Signature 

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

Profile
 
 
Posted: 02 January 2012 05:07 AM   [ Ignore ]   [ # 514 ]  
Summer Student
Total Posts:  14
Joined  10-06-2011

Can you help me :(

Profile
 
 
Posted: 02 January 2012 05:23 AM   [ Ignore ]   [ # 515 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

I have already given you help for using Tank Auth as a module. If you need further assistance with Tank Auth itself, I recommend that you ask in the Tank Auth thread.

 Signature 

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

Profile
 
 
Posted: 03 January 2012 01:03 AM   [ Ignore ]   [ # 516 ]  
Summer Student
Total Posts:  11
Joined  12-29-2011

@huy get a fresh install on both codeigniter and tank auth ( as im not sure what changes you made). then setup HMVC. after that create a folder called module then copy the tank auth application folder into the module folder. after that go into the tank auth application folder then into “views”  you will see “email” and “auth” inside both of those folders are files you must move to tank auths “views” folder. So in other words all the view that are currently in the 2 folders must move.

Profile
 
 
Posted: 03 January 2012 02:01 AM   [ Ignore ]   [ # 517 ]  
Summer Student
Total Posts:  14
Joined  10-06-2011
iScotts - 03 January 2012 01:03 AM

@huy get a fresh install on both codeigniter and tank auth ( as im not sure what changes you made). then setup HMVC. after that create a folder called module then copy the tank auth application folder into the module folder. after that go into the tank auth application folder then into “views”  you will see “email” and “auth” inside both of those folders are files you must move to tank auths “views” folder. So in other words all the view that are currently in the 2 folders must move.

I did but still will not run. Bug and bug. Tank Auth so bad in HMVC !!

 

Profile
 
 
Posted: 14 January 2012 05:45 AM   [ Ignore ]   [ # 518 ]  
Summer Student
Total Posts:  11
Joined  12-29-2011

ok im having trouble loading a controller from another module and using its functions. I tried with two modules, the welcome module and a test module and i tried to call the index function from the welcome class and this is the error i get

Unable to load the requested filewelcome_message.php 

. this is how my test class index function looks

<?php

class test extends CI_Controller {
    
    
function index()
    
{
        $this
->load->module('welcome');
        
$this->welcome->index();
    
}

i also tried extending both the ci_controller and mx_controller but i cant get it to work. I reaised this when i tried calling the is_logged_in() method from tank_auth library but that doesnt work either.

Profile
 
 
Posted: 14 January 2012 07:04 AM   [ Ignore ]   [ # 519 ]  
Research Assistant
RankRankRank
Total Posts:  323
Joined  05-19-2011

I have run both tank_auth and ion_auth as modules under HMVC.

As I remember it, both of the auth libraries worked fine.

Form_validate does not play well with HMVC.

 Signature 

CodeIgniter E-Commerce Shopping Cart Software

Profile
 
 
Posted: 14 January 2012 02:26 PM   [ Ignore ]   [ # 520 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

@iScotts, This code works as it should. The Modular Extensions HMVC Bitbucket wiki page explains how to use the HMVC functionality and how to use the CI_Form_validation class properly.

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

class 
Test extends MX_Controller
{
   
function index()
   
{
        $this
->load->module('welcome');
        
$this->welcome->index();
   
}
}
/* End of file test.php */
/* Location: ./application/controllers/test.php */ 
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class 
Welcome extends MX_Controller 
{
   
function index() 
   
{
        $this
->load->view('welcome_message');
   
}
}
/* End of file welcome.php */
/* Location: ./application/modules/welcome/controllers/welcome.php */ 
 Signature 

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

Profile
 
 
Posted: 14 January 2012 03:23 PM   [ Ignore ]   [ # 521 ]  
Research Assistant
RankRankRank
Total Posts:  323
Joined  05-19-2011
wiredesignz - 14 January 2012 02:26 PM

The Modular Extensions HMVC Bitbucket wiki page explains how to use the HMVC functionality and how to use the CI_Form_validation class properly.

I just looked at the HMVC wiki and I’m not sure when it was changed but there is a new method of handling form_validation under HMVC. The code that I have in my MY_Form_validation class is:

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

class 
MY_Form_validation extends CI_Form_validation
{
 
  
public function run($module ''$group ''
  
{
      
   
(is_object($module)) AND $this->CI =& $module;
   return 
parent::run($group);
  
}
 

Which appears to be the old solution.

 Signature 

CodeIgniter E-Commerce Shopping Cart Software

Profile
 
 
Posted: 14 January 2012 04:42 PM   [ Ignore ]   [ # 522 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

@vbsaltydog, That code was used with an earlier version of Modular Extensions HMVC.
The recommended fix when using CI_Form_validation callbacks in module controllers is below

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

class 
MY_Form_validation extends CI_Form_validation 
{
    
public $CI;
}
/* End of file MY_Form_validation.php */
/* Location: ./application/libraries/MY_Form_validation.php */ 
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class 
Xyz extends MX_Controller 
{
    
function __construct()
    
{
        parent
::__construct();
        
        
$this->load->library('form_validation');
        
$this->form_validation->CI =& $this;
    
}
 Signature 

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

Profile
 
 
Posted: 15 January 2012 02:08 PM   [ Ignore ]   [ # 523 ]  
Summer Student
Total Posts:  11
Joined  12-29-2011
wiredesignz - 14 January 2012 02:26 PM

@iScotts, This code works as it should. The Modular Extensions HMVC Bitbucket wiki page explains how to use the HMVC functionality and how to use the CI_Form_validation class properly.

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

class 
Test extends MX_Controller
{
   
function index()
   
{
        $this
->load->module('welcome');
        
$this->welcome->index();
   
}
}
/* End of file test.php */
/* Location: ./application/controllers/test.php */ 
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class 
Welcome extends MX_Controller 
{
   
function index() 
   
{
        $this
->load->view('welcome_message');
   
}
}
/* End of file welcome.php */
/* Location: ./application/modules/welcome/controllers/welcome.php */ 


Ok I found my problem, my welcome controller did not extend MX instead they extended CI the minute i changed that it worked and i would have never noticed had you not posted the welcome controller. Thank you!!

Profile
 
 
Posted: 29 February 2012 04:05 PM   [ Ignore ]   [ # 524 ]  
Summer Student
Avatar
Total Posts:  23
Joined  04-13-2006

I’m sure I’ve got something wrong, but I’ve been through the documentation and examples and I’m just not seeing it. I’m using CI 2.1.0 & the latest HMVC.

I am getting the following error: Fatal error: Cannot redeclare class CI in ../application/third_party/MX/Base.php on line 57

Here is the call:

modules::run("entries/controllers/entries/get_entry",$params); 

And here is the controller:

class Entries extends MX_Controller {

 
function __construct()
 
{
  parent
::__construct();
 
}

 
public function get_entry($params)
 
{
  print_r
($params);
 

See anything wrong?
The controller is in a module, the call is coming from an outside library. Could that be the culprit? I have the same issues when using $this->load->module (or $this->CI->load->module() ).

Thanks,
Scott

Profile
 
 
Posted: 01 March 2012 03:17 AM   [ Ignore ]   [ # 525 ]  
Grad Student
Rank
Total Posts:  62
Joined  01-10-2011
modules::run("entries/get_entry",$params); 

if the folder name and the controller name are the same…

 Signature 

programming is an expression of yourself…

Profile
 
 
   
35 of 36
35