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]
  • #91 / Jan 28, 2010 12:05pm

    ralf57

    52 posts

    Hi all,
    I need to load a view from a different location other than those in module and application folders.
    To achieve this I am setting

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

    before calling

    $this->CI->load->view($view, $data, TRUE);

    in my controller.

    The problem is that the method actually called is the one in application/libraries/MY_Loader.php
    Is there a way to to call the overridden “view” method (the one defined in system/libraries/Loader.php?
    Thanks in advance, ralf

  • #92 / Jan 31, 2010 11:47pm

    dinhtrung

    63 posts

    Hi all,
    I don’t see Modular Separation activate the ‘index’ method as default for module controllers. Is there any other way to bypass the uri segment ‘index’, rather than to configure routes?

  • #93 / Feb 03, 2010 4:37am

    umefarooq

    690 posts

    Hi @wiredesignz you library is really good and working fine for me but i have some problem which im facing with modular separation is that is not calling member function of MY_Language and MY_Config of any other library is using. it always checking MX_Language and MX_Config classes in you MY_Loader library. i have check the modular separation with following library

    http://maestric.com/doc/php/codeigniter_i18n

    How can we solve this problem

    EDITED
    i have fixed it by extended your MX_Language and MX_Config class with MY_Lanugage and MY_Config file just want to confirm is OK to do so.

  • #94 / Feb 06, 2010 6:42am

    mooooo

    5 posts

    Hi all! First off thanks for this great library!

    I have a problem when I try to load a model from a controller.

    My folder structure is as follows:

    application
    - controllers/admin.php
    - modules/blog
      - controllers/blog.php
      - models/blog_model.php
    - modules/category
      - controllers
      - models/category_model.php

    From my blog controller I try to following:

    function __construct() {
      parent::Controller();
      $this->load->model('blog_model');
      $this->load->model('category_model');
    }

    The first model, blog_model, is loaded without any problem but the category_model cannot be found. Am I suppose to add more to the model url to be able to load a different model in my blog controller?

    Thanks and regards!

    ##### EDIT #####

    Ahh I’m just crazy today. Noticed that it’s as simple as just adding the module name in front of the model name as such:

    $this->load->model('category/category_model');
  • #95 / Feb 06, 2010 6:52am

    shinokada

    144 posts

    Isn’t it like this?

    $this->load->module_model('blog','blog_model');

    And same for the others?

  • #96 / Feb 10, 2010 9:46am

    kilishan

    183 posts

    First off, love the library. Seems to be MUCH faster than Matchbox. So far I’m thrilled to have made the switch. However, I’m running into a problem trying to load language files.

    I have a core_module in ‘application/core_modules/pages’. The language file is located in /application/core_modules/pages/language/english/pages_lang.php’.

    In my CMS, I’m using the language files to load the names and descriptions of all of the modules so that I can handle enabling/disabling them. Here’s the call in my modules model:

    public function get()
        {
            // Get list of directories
            $map = scandir(APPPATH.'modules/');
    
            // Build our modules list
            $modules = array();
            
            foreach ($map as $key => $file_name)
            {    
                if ($file_name != '.' && $file_name != '..' && is_dir(APPPATH.'modules/'.$file_name))
                {
                    $this->load->language($file_name);
                
                    $modules[] = $file_name;
                }
            }
    
            return $modules;
        }

    Whenever it runs, it spits out the following error:

    Unable to load the requested language file: language/english/welcome_lang.php

    Anyone have any ideas what I’m doing wrong, here?

    Thanks!

  • #97 / Feb 10, 2010 3:56pm

    wiredesignz

    2882 posts

    @kilishan, Try including the module name and file name if you need to cross load from another module.

    $file_path = $file_name.'/'.$file_name;
    $this->load->language($file_path);
  • #98 / Feb 10, 2010 5:28pm

    kilishan

    183 posts

    Well, crap. Thought I had tried that, but just tried again and it worked like a charm. Can’t remember for the life of me what I did differently previously, but I guess it really doesn’t matter, does it?

    Thanks for the assist!

  • #99 / Feb 28, 2010 5:38pm

    theprodigy

    653 posts

    just a quick question.

    I am able to get my controllers to extend MY_Controller just fine, but I have to use MX_Model in order for them to extend. Why is this? Why will controllers extend the default MY_, but the models need MX_?

    When I try to extend MY_Model, it tells me it’s not found, but once I change it to MX_Model, it works perfectly.

  • #100 / Feb 28, 2010 5:56pm

    wiredesignz

    2882 posts

    Modular Separation utilizes spl_autoload(), so your MX_Model parent class will be loaded for you automatically on demand. However it specifically ignores MY_ prefixed parent classes leaving those for CodeIgniter to load.

  • #101 / Feb 28, 2010 6:07pm

    theprodigy

    653 posts

    I have both the MY_Controller and MY_Model in the application/libraries folder (so that all controllers and models regardless of in a module or not can access them). So, CI should be picking these up, but it’s only picking up the Controller extension.

    The controller and model accessing these extensions are in a module.

    The controller extending MY_Controller works as expected. The Model extending MY_Model throws a ‘not found’ error on the model trying to extend it (it finds the model, but not the MY_Model it is extending).

    When I change the model extender to MX_Model (file name, class name, and extends declaration), it works as expected.

  • #102 / Feb 28, 2010 6:24pm

    wiredesignz

    2882 posts

    Extending MY_Model works perfectly fine here.

  • #103 / Feb 28, 2010 6:37pm

    wiredesignz

    2882 posts

    Modular Separation PHP5 has been updated and version 1.11 is now attached to the first post of this thread.

  • #104 / Feb 28, 2010 6:42pm

    hugle

    289 posts

    Hello
    downloaded version 1.10, installed, and after refresh, I spoted that 1.11 is already here, so downloaded the new one 😊 we’ll keep posted if some problems occur!:)

    thanks wiredesignz

  • #105 / Feb 28, 2010 10:35pm

    theprodigy

    653 posts

    ok, not sure why it’s not working for me.

    folder structure (only relevant structure showing):

    application
    —site1
    ——config
    ——controllers
    ——libraries
    ———MY_Controller.php
    ———MY_Loader.php
    ———MY_Model.php
    ———MY_Router.php
    ——models
    ——modules
    ———news
    ————controllers
    —————news.php (extends MY_Controller) <——works just fine
    ————libraries
    ————models
    —————news_model.php (extends MY_Model) <——throws error
    ————views
    ——views
    —site2
    ——[folder structure not shown]
    system
    —171
    ——(CI 1.7.1 system folder structure)
    —172
    ——(CI 1.7.2 system folder structure)
    public_html
    —css
    —images
    —js
    —index.php

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

ExpressionEngine News!

#eecms, #events, #releases