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]
  • #151 / Oct 05, 2010 3:28pm

    Bainzy

    149 posts

    Boris ... this is the exact reason why i chose to use it myself ... in the past i have always coded in a modular style folder setup ... but sometimes even that falls short.  What i wanted to do this type with my forums is have everything so like you say if i changed my users module ( handles all things user related .. profile, settings etc ) i could just release the module as a update .... upload it ... run a installer and have it update the site ... makes everything nice and simple.

  • #152 / Oct 05, 2010 5:45pm

    wiredesignz

    2882 posts

    In my opinion a view should only contain the final output and “helpers” calls and should not load any data

    If you look at CI documentation they often load a view from within another view.

    But nowhere does it state in the CI docs or HMVC wiki that you are forced to load views this way.

  • #153 / Oct 05, 2010 5:56pm

    ralf57

    52 posts

    I think the biggest advantage is organizing your code into modules. ...

    I also like to keep things organized in modules but this is different from using the HMVC “features”.
    In fact you can have modules (Modules Separation) without HMVC.
    Fans of the HMVC pattern often bring the “widget problem” as a key argument basically assigning the view a role that it should not have.
    As an example,provided a “latest_news.php” view:

    modules::run('content/news/latest', $param);

    1) you still have to pass $param if you want to customize the results
    2) you introduce some logic in the view, defeating the nice separation provided by the MVC pattern

    Not a big deal, in my opinion

  • #154 / Oct 05, 2010 6:04pm

    ralf57

    52 posts

    But nowhere does it state in the CI docs or HMVC wiki that you are forced to load views this way.

    You’re right, but apart from this usage (calling a module from a view) I can’t find any other big advantage over the standard MVC approach.
    If you have some examples of what cannot be achieved without the HMVC, please post them here.
    Just to clarify, I don’t have anything against HMVC, I am only trying to understand it a bit more

  • #155 / Oct 08, 2010 7:16am

    asylmottaket

    28 posts

    Suggestion:

    $this->load->module(‘module/controller’, ‘new_name’);
         
    $this->new_name->method();


    Just like the alias on models

  • #156 / Oct 12, 2010 9:07pm

    rhbecker

    1 posts

    I’m in the process of transitioning from Modular Separation to Modular Extensions, and it seems I’ve lost the ability to do 2 things I had grown accustomed to. I’m trying to determine whether I lost them because of some error on my code, or whether they are simply not supported.

    1. In MS, I was doing stuff like ...
    application/config/autoload.php
    application/modules/example_module/config/autoload.php
    ... and the module had access to anything loaded in either place.

    2. In MS, if I had ...
    application/modules/example/controllers/example.php
    application/modules/example/config/example.php
    ... the latter was autoloaded.

    Thanks in advance.

  • #157 / Oct 13, 2010 12:01am

    Vheissu

    278 posts

    I’m having an issue getting config files inside of my modules to be recognised.

    I have a module called ‘auth’ inside of my application/modules folder. Inside of that I have a config folder and in the config folder I have a config file called ‘ion_auth.php’ I am basically trying to add Ion_auth into a module.

    Inside the Ion_auth library file a new instance of CI is being stored by $this->ci = &get;_instance(); and then config files for Ion_auth are loaded like this:

    $this->ci->load->config('auth/ion_auth', TRUE);

    Auth is the name of my module and it should be working, but doesn’t appear to be. Even without adding in Auth part it still doesn’t find the config file and I get the below error:

    The configuration file auth/ion_auth.php does not exist.

    I noticed that PyroCMS uses Ion_auth inside of a module called users and it appears to work fine, but I also noticed that Phil has made some tweaks, combined the MX files from Modular Extensions into the one class, so I’m not sure if further modification is required to get config files inside modules loading.

    Any help? I’m using Codeigniter 2 (latest version from BitBucket).

  • #158 / Oct 13, 2010 5:20am

    Phil Sturgeon

    2889 posts

    I’m having an issue getting config files inside of my modules to be recognised.

    I have a module called ‘auth’ inside of my application/modules folder. Inside of that I have a config folder and in the config folder I have a config file called ‘ion_auth.php’ I am basically trying to add Ion_auth into a module.

    Inside the Ion_auth library file a new instance of CI is being stored by $this->ci = &get;_instance(); and then config files for Ion_auth are loaded like this:

    $this->ci->load->config('auth/ion_auth', TRUE);

    Auth is the name of my module and it should be working, but doesn’t appear to be. Even without adding in Auth part it still doesn’t find the config file and I get the below error:

    The configuration file auth/ion_auth.php does not exist.

    I noticed that PyroCMS uses Ion_auth inside of a module called users and it appears to work fine, but I also noticed that Phil has made some tweaks, combined the MX files from Modular Extensions into the one class, so I’m not sure if further modification is required to get config files inside modules loading.

    Any help? I’m using Codeigniter 2 (latest version from BitBucket).

    Heh I haven’t made any tweaks, PyroCMS is still using my old fork of Modular Separation which is now part of Modular Extensions again.

  • #159 / Oct 13, 2010 6:22am

    Vheissu

    278 posts

    Oh, I see. I guess I am just presuming that you modified something because the core files are combined into the one class in your CMS. I still can’t work out what is going on, so I’ll provide some extra detail in the hopes that someone can assist me.

    Here is MY_Controller:

    require APPPATH."third_party/MX/Controller.php";
    
    class MY_Controller extends MX_Controller {
        
        public $CMS;
        
        // Setting variables
        public $settings = array();
            
        public function __construct()
        {
            // Constructor
            parent::__construct();
            
            // Get instance of Codeigniter object
            $this->CMS = &get;_instance();
            
            // Gets settings from database
            $this->_init_settings();
                    
        }
        
        // Gets settings from database and stores them
        public function _init_settings()
        {
            $settings = $this->db->get('settings');
        
            foreach ($settings->result_array() as $row)
            {
                // go through the settings table and pull out lots of stuff
                $this->config->set_item($row['setting_name'], $row['setting_value']);
                
                // set MY_Controller variables (to save function class to config)
                $this->settings[$row['setting_name']] = $row['setting_value'];
            }     
        }
        
    }

    I have MY_Controller, MY_Loader and MY_Router inside of the core directory inside of my application directory. In my libraries folder I have Dwoo and MY_Router (same code you posted on your blog Phil) for using Dwoo with the Codeigniter parser.

    Inside of my auth module I have the following directories and files:

    Auth
      Config
      ion_auth.php
      Controllers
      auth.php
      Language
      (a whole heap of language directories for multiple languages from Ion Auth)
      Libraries
      Ion_auth.php
      Models
      ion_auth_model.php
      Views
      (just the views that come within the download Ion auth package)

    In my application/config/routes.php file I have the following code:

    $route['default_controller'] = "pages/pages";    // Pages controller is the default controller
    $route['admin']              = "admin";          // Main admin controller
    $route['(:any)/admin']       = "$1/admin";       // Individual module admin controllers
    $route['(:any)']             = "pages/pages/$1"; // Every request to the pages controller

    If there is anything else I can supply, please let me know. I would really like to get config files in my modules to load. Is there perhaps another hacky way like including the config file if I can’t get it to work and nobody can help me?

    Thank you.

  • #160 / Oct 13, 2010 11:48am

    Saniok

    1 posts

    Hi to all!

    I’m using CodeIniter 2 with Modular Extensions and I have a question. Is there any intelligent way to deny access to module controllers by URL? So it will be accessible only from other controllers.

    I can use unserscore in function names (_myFunction) but maybe there is another predefined in ME way?

    Thanks a lot!

  • #161 / Oct 13, 2010 2:21pm

    wiredesignz

    2882 posts

    @Saniok, Yes use the _remap() method in your controllers and redirect or generate an error from there.

  • #162 / Oct 14, 2010 5:21am

    MANZ LEE

    1 posts

    Join OK!!!!

  • #163 / Oct 16, 2010 3:30pm

    ralf57

    52 posts

    Hi all,
    I have troubles loading the view from a custom path (ex.from a theme)
    I used to do this

    $this->load->_ci_view_path = 'my/custom/path'

    but using ME, this is set in MX_Loader::view and only module/application views are taken into account.
    Is there a way to override this?

    [SOLVED] I figured out myself it required a relative path

  • #164 / Oct 19, 2010 4:25pm

    danielbertini

    13 posts

    I trying use HMVC 5.3.4 with CI 2.
    In localhost using MAMP work but in server at HostGator not work.

    I get error: Fatal error: Class ‘MX_Config’ not found in /home/empre/public_html/application/third_party/MX/Base.php on line 71

    Someone can help with this?

  • #165 / Oct 19, 2010 5:59pm

    wiredesignz

    2882 posts

    If HMVC works on localhost (MAMP) but not on HostGator then the problem is not HMVC. Your code or HostGator setup is the problem.

    It would be helpful if you provided more information also! 

    Are you using HMVC features or only Modular Separation?

    Which MY_ extension files are located in application/core and application/libraries?

    Do you have CI logging enabled? What are the errors if any?

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

ExpressionEngine News!

#eecms, #events, #releases