Welcome Guest, Not a member yet? Register   Sign In
Need some help with HMVC
#1

[eluser]Unknown[/eluser]
Hi,

I'm trying to find out how HMVC works and how i can build modules with this extension. But it will not work.

At the moment i have the following PHP error: "PHP Fatal error: Cannot redeclare class CI"

This is what I'm trying to do:

I have a controller (application/controllers/aController.php) that looks like this:
Code:
class aController extends CI_Controller{
public function index(){
  $testoutput['test'] = Modules::run('test/test');
  $output['mainContent'] = $this->load->view("aView", $testoutput);
  $this->load->view('templates/maintemplate', $output);
}
}

And this is the code of my test module (application/modules/test/controllers/test.php
Code:
class Test extends MX_Controller {
public function index()
{
  $this->load->view('test');
}
}

when i visit http://localhost/test it works fine, but i can't add the module to the output of a normal controller. When i visit http://localhost/aController.php i get a blank page with the error of above in my logs.

What am i doing wrong?
#2

[eluser]InsiteFX[/eluser]
All Controllers have to extend the MX_Controller
#3

[eluser]porquero[/eluser]
If you use hmvc, I recommend don't use /application/controllers directory anymore. Always use modules drectory and all you controllers must extends MX_Controller.
#4

[eluser]Unknown[/eluser]
Ok.

But how can make use of a main template when i build my pages only with modules?
#5

[eluser]porquero[/eluser]
Well you can use Decorator Design Pattern.

For more information see: http://porquero.blogspot.com/2012/02/codeigniter-work-with-template-views.html




Theme © iAndrew 2016 - Forum software by © MyBB