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.4

January 29, 2011 1:58am

Subscribe [99]
  • #61 / May 04, 2011 5:55pm

    Mr. Pickle

    124 posts

    Hi Wiredesignz,

    Thanks for your quick reply!

    If I show a 404 the visitor will see a 404 while I just want CI to ignore the module in the process where CI looks for a module in the modules/ directory based on the uri (don’t know the official term for this :D)

    I’ll explain my problem further:
    I now have a newly developed module called guestbook in the modules/ directory.
    I load this module via a view partial:

    <?=Modules::run('controller/method');?>

    No problems so far…..

    Now one of my sites just got a page called guestbook with the following full url:
    http://www.mydomain.com/guestbook

    Now the problem starts. I use a single controller ‘page’ (module page within the modules/ dir) handling all my requests. While I want CI to load this controller and handle the requests as it would do if I had no module called guestbook it only shows the module (which is set-up as a partial) Normal behaviour but not for me in this set-up 😉
    Of course I DO want to load this module this way if I use the view partial method of calling it (and not have CI load the full page guestbook)

    Hope I managed to explain it a little, if not feel free to ask for more info 😉

  • #62 / May 04, 2011 7:07pm

    Mr. Pickle

    124 posts

    I think I’ve solved it.
    I put all the logic of getting the page stuff from the database (not only content pages but EVERY page) in the page controller within the modules/.

    I now put all this logic in a MY_controller so that this logic is not skipped whatever module is loaded (all module controllers extend this MY_Controller)

  • #63 / May 04, 2011 9:24pm

    wilso417

    36 posts

    MX_Router::fetch_module() only returning ‘last module controller loaded’ creates a problem with loading/using multiple language files as well. 

    This seems to be a pretty big bug if you want to use HMVC in a non-linear fashion of just load/use controller, load/use controller, etc.

  • #64 / May 04, 2011 10:23pm

    wiredesignz

    2882 posts

    @wilso417,  It is not a bug. The fetch_module() method does the job it was designed to do.

    If you care to look you’ll see that each controller loader object stores the correct module name.

    If you require more functionality, write it yourself.

  • #65 / May 04, 2011 10:36pm

    wilso417

    36 posts

    I’m sorry, it just seemed like a bug, I did not mean to offend.  It seemed like a bug because I thought this situation would be possible:

    class Test2 extends MX_Controller {

    public function index() {

    $this->lang->load('test2');
    echo $this->lang->line('test_me');
    }
    }

    class Test1 extends MX_Controller {

    public function index() {

    $this->load->module('test2');
    $this->test2->index();

    $this->lang->load('test1');
    echo $this->lang->line('test_this');
    }
    }

    where the language files are in their respective modules folder.  This will not work because lang is looking in the test2 folder when i try to load ‘test1’ language file.

  • #66 / May 04, 2011 10:43pm

    wilso417

    36 posts

    I think the issue is, that ‘lang’ is a library.  Libraries have no way of knowing what module called it as far as I can tell.

  • #67 / May 04, 2011 11:00pm

    wilso417

    36 posts

    In Lang.php line 55 changing to:

    $_module = CI::$APP->load->_module; (where _module was changed to public in Loader.php)

    does not fix the situation either, this will only look in ‘test1’.  Am I correct in assuming there is no way for a library to know what controller called it?

  • #68 / May 05, 2011 12:15am

    wiredesignz

    2882 posts

    @wilso417,
    In Modular extensions CI::$APP is the application (super) object. Not a controller.

    Try passing $this->load->_module when you load the language file in the lang->load() parameter?

    $test1 = $this->load->_module;
    $this->lang->load($test1.'/test_this');
    
    
    $test2 = $this->load->_module;
    $this->lang->load($test2.'/test_me');
  • #69 / May 05, 2011 12:58pm

    wilso417

    36 posts

    Thank you @wiredesignz.  I have been doing that method as a workaround.  I was just hoping there was a better solution, that there was a way for a library to know what module called it, that is all.  I have not found a way though and I think the way you showed is the only solution. 

    Thank you again for all your hard work on MX.  I wish they would make it part of CI.  If it wasn’t for this extension I would have gone with Kohona for my CMS project.

  • #70 / May 10, 2011 11:24am

    fewds

    2 posts

    I would like to delete the default controllers, models, views folders located under application. I have tried and as soon as I delete the default controllers folder everything seems to go nuts (Your default controller cannot be found….blah….blah), would you happen to know of a quick fix to make it work again? I can get it to work by leaving a blank controllers folder under application (but thats ugly!) so I assume somewhere in CI 2.0.2 its making sure this folder exist before proceeding. However I have looked everywhere and finally gave in and figured I asked on here since I believe someone else might have tried this before as well. Thanks for your time and again thanks for making CI HMVC capable!

    Steven.

  • #71 / May 10, 2011 11:43am

    Andy78

    91 posts

    Are there any compatibility issues between Modular Extensions - HMVC version 5.4 and datamapper orm 1.8?

  • #72 / May 10, 2011 1:34pm

    fewds

    2 posts

    Ok I was able to hack up CI but I know this is not the correct thing to do since it will break on upgrades. So please if anyone has a better solution let me know. But basically this is what I changed in order to get rid of the three default folders (application/controllers, application/models, and application/views) this change was needed since it looks for the controllers folder under the default application folder but since I’m using HMVC I don’t want the default three folders! Anyhow he was the quick fix I came up with.

    In the system/core/CodeIgniter.php file around line 243 to 248 I changed it from:

      if ( ! file_exists(APPPATH.‘controllers/’.$RTR->fetch_directory().$RTR->fetch_class().EXT))
      {
    show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
    }

      include(APPPATH.‘controllers/’.$RTR->fetch_directory().$RTR->fetch_class().EXT);

    to:

      if ( ! file_exists(APPPATH.(str_replace(’../’,’‘,$RTR->fetch_directory())).$RTR->fetch_class().EXT))
      {
    show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
    }

      include(APPPATH.(str_replace(’../’,’‘,$RTR->fetch_directory())).$RTR->fetch_class().EXT);

  • #73 / May 13, 2011 1:07am

    tobi15

    1 posts

    When I try to load a library with the same name from 2 different modules and assign a custom object name to one of them via load(‘name’, NULL, ‘new_object_name’) the second library doesn’t get loaded.

    I think this is the code in the MX_Loader that prevents loading 2 identical named libraries even though a different object name has been assigned… Shouldn’t that be possible since it is with the native CodeIgniter Loader class…

    if (isset($this->_ci_classes[$class]) AND $_alias = $this->_ci_classes[$class])
          return CI::$APP->$_alias;

    Is there a way to do it i’m not aware of ? or a fix somewhere ?

    Thanks for this great extension wiredesignz

  • #74 / May 14, 2011 10:55am

    osci

    377 posts

    After updating to latest version for multilanguage sites i came across this issue

    I was loading lang files after having done a modules::run
    so the last fetch_module() would return the last activated module and that resulted in language file not found error


    I reverted line 38 in MX_Lang.php
    from

    public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')    {

    to

    public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '',$_module = NULL)    {

    and line 51 in MX_Lang.php
    from

    $_module = CI::$APP->router->fetch_module();

    to

    $_module OR $_module = CI::$APP->router->fetch_module();


    and it did the trick.

    with current code i have to write

    $this->load->language('module_name/filename', $language)

    instead of

    $this->load->language('filename', $language)

    ?

    Are there any issues/reasons that made the change in MX_Lang.php?

  • #75 / May 14, 2011 1:28pm

    Welkineins

    1 posts

    When I try to load a library with the same name from 2 different modules and assign a custom object name to one of them via load(‘name’, NULL, ‘new_object_name’) the second library doesn’t get loaded.

    I think this is the code in the MX_Loader that prevents loading 2 identical named libraries even though a different object name has been assigned… Shouldn’t that be possible since it is with the native CodeIgniter Loader class…

    if (isset($this->_ci_classes[$class]) AND $_alias = $this->_ci_classes[$class])
          return CI::$APP->$_alias;

    Is there a way to do it i’m not aware of ? or a fix somewhere ?

    Thanks for this great extension wiredesignz

    I have the same problem when I’m trying to load partial views in one page (Modules::run()).

    I think this is cause by Modules::run using the same CI instance to do its job!

    Is there any possible to isolate them? Thanks.

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

ExpressionEngine News!

#eecms, #events, #releases