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 2.1.8

February 20, 2008 12:02am

Subscribe [6]
  • #91 / Feb 23, 2008 6:13pm

    wiredesignz

    2882 posts

    @Edemilson:
    Modules is only a static helper class, it isn’t meant to be instantiated. The HMVC class is extended by your module… I suppose it could be called Module.

    So your code would look like:

    class Setup extends Module
    {
        function Setup()  {}
    }

    Would that be easier?, Although class names aren’t really important.


    RE: get_instance() above,  thank you Edemilson, that code isn’t needed now. 😉

  • #92 / Feb 23, 2008 6:27pm

    wiredesignz

    2882 posts

    Current Version is 2.1.4
    Removed redundant &ci;from run method. Thanks Edemilson,
    Renamed HMVC class to Module class.

    Created a wiki entry: Modular Extensions - (HMVC)

  • #93 / Feb 23, 2008 10:28pm

    badgeek

    26 posts

    i got error when trying to load library inside a module, is this a bug?

    A PHP Error was encountered
    Severity: Warning
    Message: Invalid argument supplied for foreach()
    Filename: libraries/Calendar.php
    Line Number: 80

    class Test extends Module
    {
        function Test()
        {
            parent::Module();
        }
        
        function index()
        {
            $this->library('calendar');
        }
        
        
    }

    in controller

    modules::run('test')

    thanks

  • #94 / Feb 23, 2008 11:17pm

    Edemilson Lima

    241 posts

    Would that be easier?, Although class names aren’t really important.

    I believe it is important when the name is more informative, more verbose and have been more to do with the thing it represents. In CI we use “class ABC extends Controller” and “class DFG extends Model”, so it is more naturally to use “class HJK extends Module” than “class LMN extends HMVC”. It is more intuitive, I think. 😊

    But the Modules class, if we never need to direct reference it in our applications, I think you can call it HMVC.

  • #95 / Feb 23, 2008 11:27pm

    wiredesignz

    2882 posts

    @badgeek
    Classes must be loaded in the module constructor. if using PHP4, PHP5 can load anywhere.

    class Test extends Module
    {
        function Test()
        {
            parent::Module();
            $this->load->library('calendar');
        }
        
        function index()
        {
            // $this->calendar->do_stuff();
        }
    }

    I get the error too, So I’m checking how the calendar library works before I comment.


    EDIT: Calendar library checks for a config array when loaded.

    $this->load->library('calendar', array());    //array() prevents error

    I’ll check module load and fix that.

  • #96 / Feb 24, 2008 12:06am

    wiredesignz

    2882 posts

    Current version is 2.1.6
    Fixed bug in loading libraries and plugins from a module. Thanks badgeek.
    Improved class loader

  • #97 / Feb 24, 2008 8:20am

    wiredesignz

    2882 posts

    Current version is 2.1.7
    Modules can be autoloaded when the modules helper is loaded.
    Create a modules.php file in application/config.
    Add entries as needed.

    Use as pre-controller hooks maybe?

    Modules can also extend CI base classes.

  • #98 / Feb 24, 2008 7:16pm

    wiredesignz

    2882 posts

    Current version is 2.1.8
    seperated module load_class and assign_libraries methods

  • #99 / Feb 24, 2008 10:34pm

    Edemilson Lima

    241 posts

    function &load;($modules, $base = 'modules/', $path = '')
    function run;($module, $data = '', $method = 'index')

    I think you must separate the “&” from “load”, otherwise the web site puts a “;” after the “load”...
    But there are some extras “;” in the code.

  • #100 / Feb 24, 2008 11:16pm

    wiredesignz

    2882 posts

    Thansk Edemilson, fixed it up. 😉

  • #101 / Feb 24, 2008 11:51pm

    wiredesignz

    2882 posts

    If your are running Modular Extensions on PHP4 and re-assigning a module name, you need to use this syntax.

    $this->search =& modules::load('search_module');  // use =& to obtain a reference to the module object.

    PHP5 is referenced by default.

  • #102 / Feb 25, 2008 8:26am

    Edemilson Lima

    241 posts

    Modules is only a static helper class, it isn’t meant to be instantiated. The HMVC class is extended by your module… I suppose it could be called Module.

    One last thing… I’m not sure if the Modular Extensions is just a helper or it is a library. For me, it is a library that have a helper inside. Even more, it is in the same level of Controller and Model libraries. In my opinion, it should go to “application/libraries”, with the name “Module.php”.

  • #103 / Feb 25, 2008 1:32pm

    Rick Jolly

    729 posts

    Modules is only a static helper class, it isn’t meant to be instantiated. The HMVC class is extended by your module… I suppose it could be called Module.

    One last thing… I’m not sure if the Modular Extensions is just a helper or it is a library. For me, it is a library that have a helper inside. Even more, it is in the same level of Controller and Model libraries. In my opinion, it should go to “application/libraries”, with the name “Module.php”.

    If it was a library, then CI would instantiate it when it’s loaded. That doesn’t make sense. If you want to make it a true CI helper instead of a static class then change the methods. For example:

    - run() becomes modules_run()
    - so to call it, modules::run() becomes modules_run()

  • #104 / Feb 25, 2008 2:20pm

    Edemilson Lima

    241 posts

    In my view, a helper is a standalone function and a library is a set of functions or classes that work together. It doesn’t matter if it can be instantiated or not, unless the library concept in CI only applies to intantiable classes. Anyway, I do prefer to use modules::run() than modules_run(). 😊

    By the way, what do you think about the version 3.0? Is it more a library than a helper or not?

    http://ellislab.com/forums/viewthread/72580/

  • #105 / Oct 01, 2008 3:39am

    nizsmo

    41 posts

    Hi, sorry to post in a old thread, just wondered if any experts here could help me with a problem which I have with HMVC? Details of the problems and description here:
    http://ellislab.com/forums/viewthread/92383/

    Many thanks in advance! 😊

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

ExpressionEngine News!

#eecms, #events, #releases