Welcome Guest, Not a member yet? Register   Sign In
HMVC not working trying to show view partial in CI 3.1.4
#1

Hello, I started using HMVC today (https://bitbucket.org/wiredesignz/codeig...sions-hmvc) and I've got to put the code to work as a module modifying MX_Loader (there was a missing function so I read), but when I tried to show the module as a view partial I get this error "Fatal error: Cannot redeclare class CI in C:\Datos\www\gastronegocios\application\third_party\MX\Base.php on line 57". This is my code:

Module Controller
PHP Code:
class Ivanblue extends MX_Controller {
 
  function __construct()
 
  {
 
     parent::__construct();
 
     date_default_timezone_set("America/Asuncion");

 
     $this->load->helper("url");
 
  }

 
  public function index()
 
  {
 
     $this->load->view("ivanblue");
 
  }


Module View
Code:
<p>
  <strong>Testing HMVC in <em>CodeIgniter</em></strong>
</p>

When I go to the controller directly at "http://localhost/gastronegocios/ivanblue" it works perfectly, but when I try to use it as a view partial I get the error "Fatal error: Cannot redeclare class CI in C:\Datos\www\gastronegocios\application\third_party\MX\Base.php on line 57".

This is how I'm trying to show it as a view partial, inside a normal view:
Code:
html code...
<?php echo modules::run("ivanblue"); ?>
html code...

How can I get this working? Thanks in advance.
Reply
#2

Hello, I found the solution. It was that my Home controller also should extend MX_Controller, not just the controllers at the modules folder. This is a really useful feature to have.

Thanks!
Reply
#3

The best way is to create a MY_Controller extending the MX_Controller
then extend all of your controllers from the MY_Controller.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB