ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Modular Extensions - HMVC version 5.3

August 30, 2010 3:03am

Subscribe [81]
  • #136 / Oct 02, 2010 8:41pm

    Boris Strahija

    129 posts

    I’m having the issue that I can’t load any CI libraries. I installed ME like it says in the instructions but loading the cart library just doesn’t work: I’m always getting:
    Message: Undefined property: CI::$cart
    Filename: MX/Loader.php
    Line Number: 143

    And another question. I would like to use ME for my CMS, so I can create modules for various sections. Eg.
    modules/dashboard/...
    modules/content/...
    modules/users/...
    modules/newsletter/...

    That’s all fine, but I would like to have those modules loaded with the URL http://mysite.com/backend/dashboard. Notice the “backend” segment. That one should be first.
    And I would also have a “frontend” module, that would get loaded without that backend segment. Something like the “404_override” route which I’m using now.

    I would really appreciate some feedback on this. Thanx.

  • #137 / Oct 02, 2010 10:26pm

    wiredesignz

    2882 posts

    @Boris Strahija, You may have a problem with your installation if you cannot load libraries. Try a clean installation with Modular Extensions version 5.3

    The module set up for your application would be something like:

    modules/backend/controllers/dashboard

    There is no 404_override route in Modular Extensions version 5.3, But there is a 404 route?

  • #138 / Oct 03, 2010 2:15am

    Vheissu

    278 posts

    I’m having the issue that I can’t load any CI libraries. I installed ME like it says in the instructions but loading the cart library just doesn’t work: I’m always getting:
    Message: Undefined property: CI::$cart
    Filename: MX/Loader.php
    Line Number: 143

    And another question. I would like to use ME for my CMS, so I can create modules for various sections. Eg.
    modules/dashboard/...
    modules/content/...
    modules/users/...
    modules/newsletter/...

    That’s all fine, but I would like to have those modules loaded with the URL http://mysite.com/backend/dashboard. Notice the “backend” segment. That one should be first.
    And I would also have a “frontend” module, that would get loaded without that backend segment. Something like the “404_override” route which I’m using now.

    I would really appreciate some feedback on this. Thanx.

    I had the exact same issue. It seems to happen when you extend just controller instead of extending MX_Controller. Try extending MX_Controller and the issue should fix itself, not idea as to why though.

    I’m using the latest install of XAMPP on my machine that I am encountering these issues on.

  • #139 / Oct 03, 2010 2:49am

    wiredesignz

    2882 posts

    I had the exact same issue. It seems to happen when you extend just controller instead of extending MX_Controller. Try extending MX_Controller and the issue should fix itself, not idea as to why though.

     

    Read the wiki page and even this thread again.
    “Controllers or their base controller must extend the MX_Controller class if you wish to use HMVC”
    “Controllers may extend the Controller class if you only require modular separation”

  • #140 / Oct 03, 2010 3:24am

    Vheissu

    278 posts

    I had the exact same issue. It seems to happen when you extend just controller instead of extending MX_Controller. Try extending MX_Controller and the issue should fix itself, not idea as to why though.

     

    Read the wiki page and even this thread again.
    “Controllers or their base controller must extend the MX_Controller class if you wish to use HMVC”
    “Controllers may extend the Controller class if you only require modular separation”

    The same issue happened with me. I didn’t want to use the HMVC features and just extended the controller like you normally would, but even though I didn’t want to use HMVC features I still had to extend MX_Controller or I had the same error messages as above.

  • #141 / Oct 03, 2010 3:47am

    wiredesignz

    2882 posts

    Then something else is wrong. Did you remove MY_Controller.php as per instructions? Are all your MY_ extension classes in the correct locations? Which version of CodeIgniter are you using? A little better explanation on your part would make diagnosis a damn sight easier.

  • #142 / Oct 03, 2010 6:29am

    Vheissu

    278 posts

    Then something else is wrong. Did you remove MY_Controller.php as per instructions? Are all your MY_ extension classes in the correct locations? Which version of CodeIgniter are you using? A little better explanation on your part would make diagnosis a damn sight easier.

    1. No MY_Controller or any other MY_ extensions of CI.
    2. I am using the latest release of Codeigniter 2.0 from Bitbucket, I check for updates as it isn’t a final release almost everyday.

    Like I said, it works when you extend MX_Controller instead of just Controller even though I don’t want to use HMVC. Not really that big of a issue to be honest. But sounds like others are experiencing the same thing.

  • #143 / Oct 03, 2010 6:40am

    wiredesignz

    2882 posts

    You must have at least MY_Loader.php and MY_Router.php in application/core for CI 2.0

  • #144 / Oct 03, 2010 7:29am

    Boris Strahija

    129 posts

    I’m testing everything with the latest versions from Bitbucket, CI and ME. The problem was extending the MX_Controller class. I also tried removing MY_Controller, end extending the Controller class, works fine. Sorry about that, didn’t read the wiki good enough 😉

    About the backend segment, I don’t it would be a good solution the way you suggested it. What would be the point in modules if I would have only 2 modules, backend and frontend? My goal is to have a module for each part of the backend (content, comments, newsletter, orders, ...), meaning that every module should have it’s own folder. The way you suggest it, all the controllers would be in modules/backend/controllers. That’s actually the default CI functionality 😊

  • #145 / Oct 03, 2010 7:41am

    wiredesignz

    2882 posts

    If you need HMVC functionality then yes controllers extend MX_Controller.

    About structure its not necessarily the CI way. HMVC allows modules controllers to call module controllers, so your functionality can still be split.

    Or you could use routes if you are faint hearted. Good luck.

  • #146 / Oct 03, 2010 8:08am

    Boris Strahija

    129 posts

    What do you mean the funcionality can be split?

    I could do it with routes but I would need to create a route for each module?

  • #147 / Oct 03, 2010 4:19pm

    Boris Strahija

    129 posts

    I think I got it working with routes:

    $route['default_controller'] = 'public';
    $route['404_override'] = 'public';
    
    $route['backend/([a-zA-Z_-]+)'] = "$1";
    $route['backend/([a-zA-Z_-]+)/(:any)'] = "$1/$2";
    $route['(:any)'] = 'public';

    Do you think it’s okay like this? Do you see any possible issues?

  • #148 / Oct 05, 2010 12:40pm

    ralf57

    52 posts

    Hi all,
    after reading a lot about the HMVC pattern I still fail to see the benefits over the traditional MVC pattern.
    Also in the wiredesignz’s Modular Extensions Wiki is stated that:

    This is most useful when you need to load a view and its data within a view

    Well, this is exactly what I want to avoid when implementing a view.
    In my opinion a view should only contain the final output and “helpers” calls and should not load any data

  • #149 / Oct 05, 2010 12:42pm

    CoolGoose

    52 posts

    Well the advantages are pretty huge actually.
    Consider that you want to show a recent news block on some pages

    Calling a function by hand in each page then passing the variable to the view, then passing the variable further to a view “partial” is a lot more ugly than just calling a module that shows only the recent news 😊

  • #150 / Oct 05, 2010 1:19pm

    Boris Strahija

    129 posts

    I think the biggest advantage is organizing your code into modules. For eg. if you’re building a CMS, you will most likely need a module for entering content. So you create ‘modules/content’, and inside folders ‘controllers’, ‘libraries’ etc. Now when you’re working on the content part of your app, everything is one folder.
    Also if you need to update a module on maybe another site it is much easier to update this one folder than to update every file separately.
    There are some other things but this is enough for me to go the HMVC way 😉

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases