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 Separation - PHP5 (Modules)

July 02, 2009 12:38am

Subscribe [88]
  • #46 / Nov 11, 2009 9:21pm

    goran_zg

    5 posts

    Sorry for this question, but what is the real difference between HMVC and this. If I only need to use modules not to have them in hierarchical order(not been able to get data from child to parent) this would be better?

    how much is the performance difference?

    anyway, great work, smth like this or this should really be in next CI release

  • #47 / Nov 11, 2009 9:30pm

    wiredesignz

    2882 posts

    ... If I only need to use modules not to have them in hierarchical order ... this would be better ...


    You are 100% correct. Thanks for explaining. 😉

  • #48 / Nov 12, 2009 2:18pm

    goran_zg

    5 posts

    Sorry for another question. I installed it on my CMS. And I get error:

    A PHP Error was encountered
    Severity: Notice
    Message: Undefined property: Frontend::$MFrontend
    Filename: controllers/frontend.php
    Line Number: 35

    This is before I even separate my code in modules. In the line I call some method from model $this->MFrontend->getMenuItem(.....);
    the same goes on every controller…

    please help, thnx

    EDIT, just to add php_error.log line for the try.
    [12-Nov-2009 19:15:39] PHP Fatal error:  Call to a member function getMenuItem() on a non-object in /Applications/MAMP/htdocs/webox/application/controllers/frontend.php on line 35

    Hope it helps couse I really want to use this module approach.

  • #49 / Nov 12, 2009 8:42pm

    wiredesignz

    2882 posts

    @goran_zg, Read the codeigniter user guide regarding naming conventions and when not to use CamelCase!

    Modular Separation requires that you use these naming conventions also.

  • #50 / Nov 12, 2009 9:08pm

    goran_zg

    5 posts

    Idiot me, I wrote the whole cms wrong…... Now pain work, and testing then 😕

    thnx

    EDIT
    Just corrected some function and this looks and works great really 😊

    Ok, another stupid q. I have a template.php file in normal view/folder it contains basic html and calls $this->load->view(smth);

    and $this->load->view($main); // this is variable what lets say screen to load and I think it looks in folder of template not modules for file defined in there how can I make it look in modules/../view for that.

    thnx

  • #51 / Nov 15, 2009 8:45pm

    wiredesignz

    2882 posts

    Modular Separation - PHP5 version 1.09 is attached to this post.

    Added $route[‘404’] routing to enable using a custom “Page not found” controller. Thanks Phil Sturgeon 😉

    EDIT:
    deprecated file removed

  • #52 / Nov 20, 2009 7:20am

    johnwbaxter

    651 posts

    This is sexy, i’m gonna start using this now.

    Nice action wiredesignz, thanks very much.

  • #53 / Nov 24, 2009 2:35pm

    AgentPhoenix

    137 posts

    I ported one of my projects from Modular Extensions to Modular Separation because is more in line with what I was looking.  Love it so far, but I’ve run in to one small issue and after looking through the code couldn’t find an obvious way to do it.  I have a template that pulls files in dynamically, but when I use the first segment of the URI, it’s my controller, not my module.  How do I find out the current module I’m executing from?

  • #54 / Nov 24, 2009 4:48pm

    wiredesignz

    2882 posts

    ...How do I find out the current module I’m executing from?

    $this->router->fetch_module();
  • #55 / Nov 24, 2009 4:49pm

    AgentPhoenix

    137 posts

    Ugh.  So simple.  I feel stupid.  Thanks, wired!

  • #56 / Nov 25, 2009 10:32am

    codex

    332 posts

    Yes modules may contain a config/routes.php file.

    The main difference from application routes, is that you set a default controller for a module like so:

    $route['module'] = 'controller';

    So, in application > config > routes.php there’s

    $route['default_controller'] = "welcome";

    and in modules > welcome > config > routes.php there’s

    $route['welcome'] = "welcome"; // is this correct?
    $route['test'] = "welcome/test";

    When you go to /test you get a 404. What am I missing here?

    EDIT: if you put the name of the controller before /test (welcome/test) then it works. Is this how it should work?

  • #57 / Nov 25, 2009 4:25pm

    wiredesignz

    2882 posts

    ... Is this how it should work?

    $route['incoming/route(.*)'] = 'controller/method$1';

    Very simple.

  • #58 / Nov 25, 2009 5:17pm

    M4rc0

    68 posts

    Can anybody provide me a file structure example of Modular Separation in use ?

    When should you use “modules” ?
    I know that if you want to have an admin interface this might be useful, but what else?

    Sorry to ask this, it’s just didn’t find any documentation about it.

    Thanks in advance!

    EDIT: Hmmm, just saw your signature about Modular Extensions. That helped understanding!
    So by using those attached files I can have modular separation without the need of a lib/plugin for it?

  • #59 / Nov 27, 2009 7:33am

    dinhtrung

    63 posts

    Hi, I’m building a modular administration portal for my company. I really like the way Wordpress construct their Library for Image, Videos, Documents and Musics.
    Is there anyway to build a “shared” modules, which will provide utilities for other modules in the system? Anyone done this task before? I want to learn how did you do it. Please, I’m in short of time for my project…
    If the module can provide another tab inside the form of other module, then that would be great. For example, something like “Comment Configuration”, with 2 options : “Enable Comments” or “Disable Comments”.  Then this module could be use for “Articles”, “Pages” and “Categories” modules : the same view, the same field.
    Any suggestion???

  • #60 / Nov 27, 2009 7:35am

    dinhtrung

    63 posts

    ...How do I find out the current module I’m executing from?

    More over, you can find out the current module, controllers, methods, and uniqueid of the object you’re interact with this:

    $this->module = $this->router->fetch_module();
                $this->controller            = strtolower(get_class($this));
                $s                             = $this->uri->rsegment_array();
             $n                             = array_search($this->controller, $s);
             $this->method                 = $this->uri->rsegment($n+1);
             $this->uniqueid            = $this->uri->rsegment($n + 2);
             log_message('info', "User accessing module : ".$this->module. " controller ".$this->controller." method ".$this->method);

    From PyroCMS! Thank Phil for his code!

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

ExpressionEngine News!

#eecms, #events, #releases