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]
  • #376 / Jan 07, 2014 4:59am

    XMadMax

    66 posts

    Hi jatin,

    I think the problem is a duplicate name in the loader, remember ever to have unique names for controllers and models:

    Rename Plugs (model) to Plugs_model, also rename the file as plugs_model.php

    Hope it helps,

    Xavier

  • #377 / Jan 07, 2014 7:12am

    InsiteFX

    6819 posts

    Make sure you specifiy your module paths in the config.php file like below.

    $config['modules_locations'] = array(
        APPPATH.'modules/' => '../modules/',
    );

     

  • #378 / Sep 13, 2014 12:20pm

    redcloud80

    31 posts

    Hi! I’m trying to use HMVC with my CI project but I’m stuck with path problems (I suppose!).

    This is my current application tree

    - application
    --- controllers
    ------ subcontrollers
    --------- first_controller.php (which extends MY_Controller)
    --------- secnd_controller.php (which extends Better_Controller)
    |...
    |...
    --- core
    ------ MY_Controller.php

    MY_Controller.php file contains two classes

    class MY_Controller extends CI_Controller
    ...
    ...
    class Better_Controller extends MY_Controller

    and works when I try to reach domain.com/subcontrollers/first_controller


    Now I’d want to move all subcontrollers to modules for HMVC

    - application
    --- modules
    ------ subcontrollers
    --------- first_controller
    ------------ controllers
    --------------- first_controller.php
    --------- secnd_controller
    ------------ controllers
    --------------- secnd_controller.php

    but when I try to hit domain.com/subcontrollers/first_controller I get a class not found error.
    I tried to remove the subcontrollers dir level and force MY_Controller to extend MX_Controller instead of CI_Controller but both attempts were not working. Any suggestion?

     

    EDIT: Removing the subcontrollers dir and forcing MY_Controller to extend CI_Controller seems to work. This is the app tree

    - application
    --- modules
    ------ first_controller
    --------- controllers
    ------------ first_controller.php
    ------ secnd_controller
    --------- controllers
    ------------ secnd_controller.php

    but how can I solve preserving the subcontrollers dir?

  • #379 / Sep 13, 2014 1:33pm

    ivantcholakov

    251 posts

    @redcloud80

    I use a modification of HMVC, anyway this might work:

    - application/
    --- modules/
    ------ subcontrollers/ (this is the module name actually)
    ---------- controllers/
    -------------- first_controller.php
    -------------- second_controller.php
    ---------- views/
  • #380 / Sep 13, 2014 1:39pm

    redcloud80

    31 posts

    @redcloud80

    I use a modification of HMVC, anyway this might work:

    - application/
    --- modules/
    ------ subcontrollers/ (this is the module name actually)
    ---------- controllers/
    -------------- first_controller.php
    -------------- second_controller.php
    ---------- views/

    Thanks, it works perfectly but it’s not a good solution for me :(

  • #381 / Sep 13, 2014 1:45pm

    ivantcholakov

    251 posts

    @redcloud80

    Another way:

    Your last solution is possible too, but within routes.php you should write rules that insert the additional subdirectory segment. It is possible, somehow I don’t like this way.

  • #382 / Sep 13, 2014 2:04pm

    ivantcholakov

    251 posts

    The third way:

    - application/
    --- modules/
    ------ subcontrollers/
    ---------- controllers/
    -------------- first_controller/
    ------------------ first_controller.php
    ------------------ why_not_another_controller.php
    -------------- second_controller/
    ------------------ second_controller.php
    ---------- views/

    This is a possible implementation on my HMVC modification, you may check whether it works with the original one.

  • #383 / Sep 13, 2014 2:31pm

    redcloud80

    31 posts

    The third way:

    - application/
    --- modules/
    ------ subcontrollers/
    ---------- controllers/
    -------------- first_controller/
    ------------------ first_controller.php
    ------------------ why_not_another_controller.php
    -------------- second_controller/
    ------------------ second_controller.php
    ---------- views/

    This is a possible implementation on my HMVC modification, you may check whether it works with the original one.

    This could work too but, unfortunately, I’ve just a single controller file for each controller… adding just another folder it’s not a solution. Nice one though 😉
    Maybe I’ll go for the routes mapping solution.

  • #384 / Sep 13, 2014 2:39pm

    ivantcholakov

    251 posts

    The radically new feature in the third way is “why_not_another_controller.php”. It is not about a single controller within a single folder. Anyway, I am glad that you can figure out how to get to your solution.

  • #385 / Sep 13, 2014 5:50pm

    redcloud80

    31 posts

    The last one proposed it’s not really modular. Subcontrollers modules cannot be ported easily to other project without “picking” each component from common models/controllers/views/libraries/etc directories. Anyway I appreciate your suggestion!

  • #386 / Sep 13, 2014 7:32pm

    InsiteFX

    6819 posts

    If your MY_Controller is extending the CI_Controller then you are using Modular Separation not HMVC

    For true HMVC your MY_Controller needs to extend MX_Controller.

    Module Structure:

    modules
    -- module_name
    ---- config - can hold routes.php etc;
    ---- controllers - the controller_name should be the same as the module_name.
                                If not then you have to access using module_name/controller_name
    -------- module_name - controller
    -------- other_controllers
    ---- libraries
    ---- models
    ---- views

    You should be able to have other directories but then you have to access then in order 1/2/3/controller etc;

     

  • #387 / Sep 13, 2014 9:15pm

    ivantcholakov

    251 posts

    @redcloud80

    It is matter of semantics what is really modular. If your “subcontrollers” folder is named “admin”, then OK, avoid the third way. The routes.php rules might be a better choice, I have seen it within PyroCMS.

    For “admin” there is the fourth way - a separate application, but that is a long story.

  • #388 / Sep 29, 2014 11:31am

    Gwynbleidd

    2 posts

    Hello,

    I have a CI project with Modular Extensions - HMVC correctly installed.

    I try to have one database settings per module.

    So, I have one application/modules/module/config/database.php file in order to create different values for these objects :
    - $active_group & $active_record variables
    - $db array

    And I would like that this file overwrites the default settings defined in the application/config/database.php file.

    - application
    --- config
    ------ database.php
    --- modules
    ------ module
    --------- config
    ------------ database.php

    This doesn’t work, CI doesn’t load the module/config/database.php file.

    Maybe I need to change some settings in autoload file ?

    Thanks to help me.

  • #389 / Sep 29, 2014 9:27pm

    InsiteFX

    6819 posts

    CI only loads it from application/config, you can set different configs in the database.php and then
    switch them later. See the database configuration in the Users Guide.

     

  • #390 / Sep 30, 2014 5:03am

    Gwynbleidd

    2 posts

    Yeah I know that but I wanted know if there’s no way to load it from module/config with HMVC.

    Because as you say, if I set different configs in the database.php I should switch them later with different value for $active_group.

    You seem tell me that it’s impossible, so I will change the $active_group value in my constructor method of my controller.

    Thanks.

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

ExpressionEngine News!

#eecms, #events, #releases