Welcome Guest, Not a member yet? Register   Sign In
Load module in the view
#1

[eluser]boytun[/eluser]
Hello
I need to load my module into my application's view, but I can't.
My module work fun if I excuted from localhost/mymodule, but if I call It from the view(echo Modules::run('mymodule')) I get this:
Code:
Cannot redeclare class CI in C:\xampp\htdocs\application\third_party\MX\Base.php on line 57

Code:
application/
+ controllers/
    + main.php (extending Frontend_Controller)->load view display
+ core/
    + MY_Controller.php (extending CI_Controller)
+modules
    + mymodule
+librairies
    +Frontend_Controller (extending MY_Controller)
+views
    +display

Thanks in advance.
#2

[eluser]Otemu[/eluser]
Hi,

Have you followed the guide here

Ensure you have done the following:
Quote:To use HMVC functionality, such as Modules::run(), controllers must extend the MX_Controller class.
Code:
<?php
class Xyz extends MX_Controller
{
    function __construct()
    {
        parent::__construct();
    }
}
#3

[eluser]boytun[/eluser]
I extend all my controller with MX_Controller like this:
Code:
application/
+ controllers/
    + main.php (extending Frontend_Controller)->load view display
+ core/
    + MY_Controller.php (extending MX_Controller)
+modules
    + mymodule
+librairies
    +Frontend_Controller (extending MY_Controller)
+views
    +display

but I get a page full of errors
#4

[eluser]TheFuzzy0ne[/eluser]
Frontend_Controller should extend MX_Controller.

MX_Controller should extend MY_Controller.

MY_Controller should extend CI_Controller.
#5

[eluser]wiredesignz[/eluser]
@fuzzy, no sorry.

The CI_Controller class cannot be used if you require the HMVC features of Modular Extensions HMVC. All controllers must extend the MX_Controller class.

You may only extend the CI_Controller class if you wish to use the module directory structure without using HMVC. In that case you must also specify which "module/resource" you wish to load within your controllers.

#6

[eluser]boytun[/eluser]
Through the post of wiredesignz, my structure became like this:
Code:
application/
+ controllers/
    + main.php (extending Frontend_Controller)->load view display
+ core/
    + MY_Controller.php (extending MX_Controller)
+modules
    + mymodule
+librairies
    +Frontend_Controller (extending MX_Controller)
+views
    +display
When I do this I get many errors like:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI::$data

Filename: MX/Controller.php

Line Number: 58

Quote:A PHP Error was encountered

Severity: Notice

Message: Indirect modification of overloaded property Page::$data has no effect

Filename: libraries/Frontend_Controller.php

Line Number: 10

Quote:A PHP Error was encountered

Severity: Notice

Message: Indirect modification of overloaded property Page::$data has no effect

Filename: controllers/page.php

Line Number: 14

And many others
#7

[eluser]TheFuzzy0ne[/eluser]
@wiredesignz

Apologies. Of course, what you're saying makes complete sense. MX_Controller extends nothing. It's a replacement for CI_Controller. As soon as I can think up a suitable project, I'll be having a play with HMVC. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB