CodeIgniter Forums
Loading module in another method doesn't work - hmvc wiredesignz - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Loading module in another method doesn't work - hmvc wiredesignz (/showthread.php?tid=65025)



Loading module in another method doesn't work - hmvc wiredesignz - happyape - 04-21-2016

I have setup Wiredesignz HMVC in a fresh CI 3 installation.

I have a controller in Modules/Commonweb/Commonweb/showprofile

I can access showprofile method via mydomain.name/commonweb/showprofile fine because (module directory name and controller names are the same)

Within that Commonweb controller I have another method called myprofile which I access using mydomain.name/commonweb/myprofile


Currently both of these method load separate view files which have almost identical code

So I thought I make use of HMVC features by calling the myprofile method in showprofile method using the format below.

PHP Code:
/** module and controller names are different, you must include the method name also, including 'index' **/
modules::run('module/controller/method'$params, $...);

/** module and controller names are the same but the method is not 'index' **/
modules::run('module/method'$params, $...);

/** module and controller names are the same and the method is 'index' **/
modules::run('module'$params, $...); 

PHP Code:
Class Commonweb extends MX_Controller
{
 
   public function __construct()
 
   {
 
       parent::__construct();
 
   }
 
   public function showprofile()
 
   {
 
       modules::load('commonweb/myprofile/');
 
   }
 
   public function myprofile()
 
   {
 
       //fetch user data and show profile
 
   }


But I just get a blank page. I tried turning on the debug messages but nothing much there.

What am I doing wrong?


RE: Loading module in another method doesn't work - hmvc wiredesignz - InsiteFX - 04-22-2016

You load the module then call the method in it:

PHP Code:
   
        $this
->load->module('template');
 
       $this->template->public_one_col($data); 

Just an example.


RE: Loading module in another method doesn't work - hmvc wiredesignz - happyape - 04-22-2016

No that's not what I am trying to achieve.


RE: Loading module in another method doesn't work - hmvc wiredesignz - ivantcholakov - 04-22-2016

I think you have to play with config/routes.php