EllisLab text mark
Advanced Search
21 of 23
21
   
Modular Extensions - HMVC version 5.4
Posted: 18 November 2012 05:45 PM   [ Ignore ]   [ # 301 ]   [ Rating: 0 ]
Avatar
Joined: 2012-07-19
32 posts
wiredesignz - 18 November 2012 05:27 PM

@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.. smile

 
Posted: 03 December 2012 05:57 AM   [ Ignore ]   [ # 302 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-09
82 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 smile

 
Posted: 03 December 2012 09:02 AM   [ Ignore ]   [ # 303 ]   [ Rating: 0 ]
Avatar
Joined: 2012-02-24
53 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
*/

 
Posted: 05 December 2012 04:39 AM   [ Ignore ]   [ # 304 ]   [ Rating: 0 ]
Joined: 2010-02-23
55 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 corelibrariesmodulesviewshelperthir_party (as HMCV..), etc...
/
system   <- codeigniter core

/wwwapp1   <- document root for   application1 (examplewww.app1.com)
/
wwwapp2   <- document root for   application2 (examplewww.app2.com )
/
wwwapp3   <- document root for   application3 (examplewww.app3.com

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/

 

 
Posted: 05 December 2012 05:11 AM   [ Ignore ]   [ # 305 ]   [ Rating: 0 ]
Joined: 2012-10-27
23 posts

Hey,

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

Greeets

 
Posted: 05 December 2012 05:46 AM   [ Ignore ]   [ # 306 ]   [ Rating: 0 ]
Joined: 2010-02-23
55 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/

 
Posted: 05 December 2012 05:49 AM   [ Ignore ]   [ # 307 ]   [ Rating: 0 ]
Joined: 2012-10-27
23 posts

Okay,

It works, thank you.

 
Posted: 12 December 2012 08:42 AM   [ Ignore ]   [ # 308 ]   [ Rating: 0 ]
Joined: 2012-12-12
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.

 
Posted: 12 December 2012 03:45 PM   [ Ignore ]   [ # 309 ]   [ Rating: 0 ]
Joined: 2012-10-14
4 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($path3);
          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_dirDIRECTORY_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 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

 
Posted: 24 December 2012 01:34 PM   [ Ignore ]   [ # 310 ]   [ Rating: 0 ]
Joined: 2012-07-04
2 posts
wiredesignz - 29 January 2011 02:58 AM

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?

 
Posted: 07 January 2013 01:20 PM   [ Ignore ]   [ # 311 ]   [ Rating: 0 ]
Joined: 2012-02-27
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

 
Posted: 08 January 2013 10:28 PM   [ Ignore ]   [ # 312 ]   [ Rating: 0 ]
Joined: 2012-07-04
2 posts

be sure that you extend MX not CI

 
Posted: 09 January 2013 04:05 AM   [ Ignore ]   [ # 313 ]   [ Rating: 0 ]
Joined: 2010-02-23
55 posts
katanama - 12 December 2012 08:42 AM

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.

 
Posted: 09 January 2013 04:08 AM   [ Ignore ]   [ # 314 ]   [ Rating: 0 ]
Joined: 2010-02-23
55 posts
MainmanFR - 07 January 2013 01:20 PM

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.

 

 
Posted: 09 January 2013 06:52 AM   [ Ignore ]   [ # 315 ]   [ Rating: 0 ]
Joined: 2012-02-27
4 posts

Hi, thanks for your reply. I resolve the problem with renaming. The module name and controller were apparently wrong ...

I encountered an other problem : i use an internationalization system and I extend both MX_Lang and MX_Config.
In the MX_Lang constructor I’ve got a :

global $CFG;
$CFG->load('language'); 

and in MX/Config.php, i’ve got an error in the load fonction :

Fatal error: Class 'CI' not found in /homez/..../application/third_party/MX/Config.php on line 42 

If I don’t extend Config, no problem. But I need to have a function i18n_url() similar to site_url() for rewrite URLs with language.

Any help wery appreciated.
Thanks in advance !

 
21 of 23
21