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]
  • #301 / Nov 18, 2012 4:27pm

    wiredesignz

    2882 posts

    @ZaLiTHkA, The Wiki page has been moved to a readme.md file in the source. Try the Overview or Source pages instead.

  • #302 / Nov 18, 2012 4:45pm

    ZaLiTHkA

    29 posts

    @ZaLiTHkA, The Wiki page has been moved to a readme.md file in the source. Try the Overview or Source pages instead.

    Ah, yes.. Got it, thanks. Did you by any chance just update the link in your forum sig? Pretty sure I tried that just now and it was still pointing to the /wiki page.. 😊

  • #303 / Dec 03, 2012 4:57am

    rei

    67 posts

    First of all, thank you so much wiredesignz for this wonderful HMVC solution in CodeIgniter.

    Anyway guys I have a question about the best practice in building decoupled modules using HMVC. Maybe someone can help me here - http://ellislab.com/forums/viewthread/230434/

    Thanks in advance 😊

  • #304 / Dec 03, 2012 8:02am

    Altazar

    52 posts

    I’m building a multilingual website and have organized parts of it in HMVC modules.
    In controllers I have this:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Site extends MX_Controller {
    
        public function __construct()
            {
            parent::__construct();
            }
    
        public function index(){
            $this->lang->load('site_language');
            $this->load->view('site_header');
            $this->load->view('site_content');
            $this->load->view('site_footer');
        }
    }

    In site_header view are country flags images with links for switching languages:

    $path = 'http://mywebsite.com/images/flags';
    echo anchor($this->lang->switch_uri('de'), img($path.'/de.png'));
    echo anchor($this->lang->switch_uri('fr'), img($path.'/fr.png'));

    It doesn’t show the flags. It worked in MVC.
    I’m autoloading URL helper but it also does not work if I load it from the module’s controller.
    If I put simple a href= and img src= HTML tags, everything works fine, but I want to have only one view file for flags used to switch language. Using HTML tags that would be not so simple.
    I’ve tried creating a flags module, but it also does not show flags.
    Maybe I should make a function which extends URL helper, I have no other idea.
    What else could cause this problem?

    Update - The problem is solved:
    https://github.com/EllisLab/CodeIgniter/wiki/CodeIgniter-2.1-internationalization-i18n

    I was using i18n version without this comment:
    /*
    in case you use it with the HMVC modular extension
    uncomment this and remove the other lines
    load the MX_Loader class
    */

  • #305 / Dec 05, 2012 3:39am

    XMadMax

    66 posts

    Hi wiredesignz, greate job I’m using HMVC from previous versions and works excelent !!

    For anyone that wants to have multiple applications sharing a ‘common hmvc core’, I have a ‘redy-to-go’ Codeginiter 2.1.2 + HMVC 5.4.

    Example:

    /application1  <-  applicacion directory as Codeginiter standard
    /application2  <-  applicacion directory as Codeginiter standard
    /application3  <-  applicacion directory as Codeginiter standard
    
    /common  <- where resides common core, libraries, modules, views, helper, thir_party (as HMCV..), etc…
    /system   <- codeigniter core
    
    /wwwapp1   <- document root for   application1 (example: <a href="http://www.app1.com">http://www.app1.com</a>)
    /wwwapp2   <- document root for   application2 (example: <a href="http://www.app2.com">http://www.app2.com</a> )
    /wwwapp3   <- document root for   application3 (example: <a href="http://www.app3.com">http://www.app3.com</a>)

    Application1, 2 and 3,  can have it’s own domain or subdomain, sharing all the common modules (/common/modules), and also can have it’s own modules (or same, overwritting common modules)


    Now, with Zend libraries (2.0.5) and Codeigniter Zend loader !!!


    A Post to download source >    http://ellislab.com/forums/viewthread/223678/

     

  • #306 / Dec 05, 2012 4:11am

    @MaxG

    14 posts

    Hey,

    Is it possible to use a /language folder in a Module?

    Greeets

  • #307 / Dec 05, 2012 4:46am

    XMadMax

    66 posts

    Hi MaxG,

    Yes, you can have a .../modules/mymodule/language/english/example_lang.php

    To load: $this->load->language(‘mymodule/example’);


    =====================================================================================
    CI 2.1.2 + HMVC 5.4 + Common shared folder for multiple applications
    http://ellislab.com/forums/viewthread/223678/

  • #308 / Dec 05, 2012 4:49am

    @MaxG

    14 posts

    Okay,

    It works, thank you.

  • #309 / Dec 12, 2012 7:42am

    katanama

    12 posts

    Hi guys…

    I’m a PHP noob and this questions might be trivial…

    1, When I do var_dump($this) in two installation of CI, one is vanilla CI, the other is CI+HMVC, I get different result.
      a. Can someone explain if this is on purpose or it’s just inevitable…
      b. Does this effect in any way the way someone code on CI.
      c. Is it something that can be rectified by some code clean up? If yes, I’d like to try when I have the time.

    2. In Base.php, the last line says

    new CI
    . A new object is instatiated without assigning it to a variable. How is it different from the common way ie.
    $CI = new CI;

    as I said, I’m a very novice programmer.

  • #310 / Dec 12, 2012 2:45pm

    dafreak

    3 posts

    So I’m still new to CI and HMVC but I have been messing around a bit and was looking at hooks and noticed that there is no auto loading of hooks from the module’s folder so here’s what I came up with

    MX/Hooks.php

    class MX_Hooks extends CI_Hooks 
    {
        /**
         * Initialize the Hooks Preferences
         *
         * @access  private
         * @return  void
         */
        function _initialize()
        {
            $CFG =& load_class('Config', 'core');
            // If hooks are not enabled in the config file
            // there is nothing else to do
            if ($CFG->item('enable_hooks') == FALSE)
            {
                return;
            }
            // Grab the "hooks" definition file.
            // If there are no hooks, we're done.
           if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
            {
                include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
            }
            elseif (is_file(APPPATH.'config/hooks.php'))
            {
                include(APPPATH.'config/hooks.php');
           }
             $path = APPPATH . 'modules/';
             $modules = $this->directory_map($path, 3);
              foreach ($modules as $key => $value) {
                    if (is_file(APPPATH."modules/{$key}/config/hooks.php")){
                        include(APPPATH."modules/{$key}/config/hooks.php");
                    }
    
            }
            if ( ! isset($hook) OR ! is_array($hook))
            {
                return;
            }
       
            $this->hooks =& $hook;
            $this->enabled = TRUE;
      
        }
        public function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
        {
            if ($fp = @opendir($source_dir))
            {
                $filedata   = array();
                $new_depth  = $directory_depth - 1;
                $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
    
                while (FALSE !== ($file = readdir($fp)))
                {
                    // Remove '.', '..', and hidden files [optional]
                    if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
                    {
                        continue;
                    }
    
                    if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir.$file))
                    {
                        $filedata[$file] = $this->directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden);
                    }
                    else
                    {
                        $filedata[] = $file;
                    }
                }
    
                closedir($fp);
                return $filedata;
            }
    
            return FALSE;
        }
    }

    and in the Core folder a file name MY_Hooks.php

    <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
    
    /* load the MX_Hooks class */
    require APPPATH."third_party/MX/Hooks.php";
    
    class MY_Hooks extends MX_Hooks {}


    its a quick and dirty solution so any (constructive) comments are welcomed

  • #311 / Dec 24, 2012 12:34pm

    ahmedmahmoudit

    2 posts

    Modular Extensions - HMVC version 5.4 is available from Bitbucket. (see my signature below)

    CodeIgniter version 1.7 is no longer supported.

    Thank you wiredesignz for Great Extension but i have question i’m already using the extension and now i want to integrate phpUnit and i don’t know if this possible with HMVC extension?

  • #312 / Jan 07, 2013 12:20pm

    MainmanFR

    4 posts

    Hello,

    I’ve got a little problem with HMVC. I call directly the URL of my module, and I’ve got a memory limit error in :

    Loader.php line 55

    in the foreach loop.

    The error shows after 1 ou 2 minutes ...

    Never had such an error.
    Any ideas please ?

    Thanks,
    Renaud

  • #313 / Jan 08, 2013 9:28pm

    ahmedmahmoudit

    2 posts

    be sure that you extend MX not CI

  • #314 / Jan 09, 2013 3:05am

    XMadMax

    66 posts

    Hi guys…

    I’m a PHP noob and this questions might be trivial…

    1, When I do var_dump($this) in two installation of CI, one is vanilla CI, the other is CI+HMVC, I get different result.
      a. Can someone explain if this is on purpose or it’s just inevitable…
      b. Does this effect in any way the way someone code on CI.
      c. Is it something that can be rectified by some code clean up? If yes, I’d like to try when I have the time.

    2. In Base.php, the last line says

    new CI
    . A new object is instatiated without assigning it to a variable. How is it different from the common way ie.
    $CI = new CI;

    as I said, I’m a very novice programmer.

    katanama, HMVC isn’t ‘over’ CI, then must to extend with CI::$APP, this is the major difference.

  • #315 / Jan 09, 2013 3:08am

    XMadMax

    66 posts

    Hello,

    I’ve got a little problem with HMVC. I call directly the URL of my module, and I’ve got a memory limit error in :

    Loader.php line 55

    in the foreach loop.

    The error shows after 1 ou 2 minutes ...

    Never had such an error.
    Any ideas please ?

    Thanks,
    Renaud

    Seem the line like .... /* references to ci loader variables */.

    Would be that you have something in your code that makes recursive assignment of variables. This loop copy all vars from CI to Loader (this), then if there are variables that points one to other, then the loop never ends.

     

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

ExpressionEngine News!

#eecms, #events, #releases