CodeIgniter Forums
HMVC issue - 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: HMVC issue (/showthread.php?tid=63360)



HMVC issue - Sentro - 10-22-2015

Hello,

I've been using Codeigniter for a while now and i want to introduce modules to my app.
I've downloaded wiredesignz latest extension ( supposed to support CI 3.x ) and i've been having trouble getting it to work.

I setup a controller named "Home" in my application/controllers folder.

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

class Home extends MX_Controller {

   public function index()
   {
       echo 'ok here we go <br>';
       echo modules::run("test/sayhello");
   }

}

Created a module with the below structure
[Image: n4tdgy.jpg]

And this is the modules controller class Test
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends CI_Controller{

   public function sayhello(){
       echo 'This is the Test sayhello function';
   }

}

When i run the URL in the browser all i get is the below "ok here we go " which is outputted by the Home controller.

What am i doing wrong ?


RE: HMVC issue - davicotico - 10-22-2015

Your class Test should extend MX_Controller:

PHP Code:
class Test extends MX_Controller{





RE: HMVC issue - Sentro - 10-22-2015

(10-22-2015, 11:16 AM)davicotico Wrote: Your class Test should extend MX_Controller:

PHP Code:
class Test extends MX_Controller{



Changed that and still now luck.
If i try
Code:
$this->load->module('test');
        $this->test->sayhello();
i get

Code:
Message: Call to a member function sayhello() on a non-object

Filename: controllers/Home.php

Now just to clarify the controller i'm trying to call the modules controller is located in "applications/controllers" not in another modules controllers.


RE: HMVC issue - Martin7483 - 10-22-2015

Hi!

Maybe you can take a look at my approach of HMVC in CodeIgniter

http://forum.codeigniter.com/thread-63078.html


RE: HMVC issue - Sentro - 10-23-2015

(10-22-2015, 03:45 PM)Martin7483 Wrote: Hi!

Maybe you can take a look at my approach of HMVC in CodeIgniter

http://forum.codeigniter.com/thread-63078.html

Hello,

I downloaded your application and any ideas why i might be getting

Code:
Message: Call to undefined function set_realpath()

Filename: core/MY_Loader.php

Line Number: 174

Codeigniter version is 3.0.02


RE: HMVC issue - Martin7483 - 10-23-2015

(10-23-2015, 12:43 AM)Sentro Wrote:
(10-22-2015, 03:45 PM)Martin7483 Wrote: Hi!

Maybe you can take a look at my approach of HMVC in CodeIgniter

http://forum.codeigniter.com/thread-63078.html

Hello,

I downloaded your application and any ideas why i might be getting

Code:
Message: Call to undefined function set_realpath()

Filename: core/MY_Loader.php

Line Number: 174

Codeigniter version is 3.0.02

Sorry about that. You need to load the path helper. I auto load it in my auto load config file and recommend you do this when using the Simple HMVC
PHP Code:
$this->load->helper('path'); 



RE: HMVC issue - Sentro - 10-23-2015

(10-23-2015, 12:54 AM)Martin7483 Wrote:
(10-23-2015, 12:43 AM)Sentro Wrote:
(10-22-2015, 03:45 PM)Martin7483 Wrote: Hi!

Maybe you can take a look at my approach of HMVC in CodeIgniter

http://forum.codeigniter.com/thread-63078.html

Hello,

I downloaded your application and any ideas why i might be getting

Code:
Message: Call to undefined function set_realpath()

Filename: core/MY_Loader.php

Line Number: 174

Codeigniter version is 3.0.02

Sorry about that. You need to load the path helper. I auto load it in my auto load config file and recommend you do this when using the Simple HMVC
PHP Code:
$this->load->helper('path'); 

Thank you, works like a charm. Actually there is also another function in system/helpers/path_helper

I'll get right into since i need something like it ASAP.
Thank you for this.


RE: HMVC issue - Martin7483 - 10-23-2015

(10-23-2015, 01:03 AM)Sentro Wrote: Thank you, works like a charm. Actually there is also another function in system/helpers/path_helper

Yes, that is the original CI set_realpath. Only the original throws an error when a file or directory does not exist. I wanted it to return FALSE when testing failed.

Hope it will help you out. Any improvements or suggestions or most welcome Smile