• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modular Extensions - HMVC version 5.4

[eluser]MainmanFR[/eluser]
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 :

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

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

Code:
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 !

[eluser]MainmanFR[/eluser]
Thanks Dafreak !!!
Exactly what I was looking for. Don't know why HMVC team never do a thing like that ! I tell you if I encounter some problems.

[quote author="dafreak" date="1355341509"]its a quick and dirty solution so any (constructive) comments are welcomed[/quote]

[eluser]Unknown[/eluser]
Hi wiredesignz. Thanks for great extension.
But i have question.
1. Can i use _output function in Controller that extended from MX_Controller.
2. Can i create Core Controller Class in application/core. And i want to use Modules::run function from that class. How can i do that

[eluser]seanloving[/eluser]
I want to call Modules::run twice within the same controller but my second call cannot find the controller method in the module that I am targeting.

For example
Code:
function index() {
// code
$headerdata['loginbar'] = Modules::run('users/forms/login');
$maindata['search'] = Modules::run('contacts/forms/search');
//code
}

gives an error on the second call
Call to undefined method Forms:Confusedearch() in \application\modules\contacts\controllers\contacts.php

If I don't make the first call then the second call finds the module controller and returns the data (form) that I expect.

Has this been discussed or observed by anyone or is this expected?
Thanks

SOLVED -- the users module and the contacts module cannot have controllers with identical names (forms). See also this explanation

[eluser]Kobus M[/eluser]
Hi Wiredesignz,

Thanks again for the plugin. It generally works very well for me, but I am really struggling with routing inside my modules.

I have routes like this in my main application/config/routes.php file

Code:
$routes[‘login’] = ‘user/login’;

So, when I go to site.com/login, I get the login screen defined in the user module.

Moving this to /modules/user/config/routes.php does not work. No permutation of this in any way. I have tried:

Code:
$routes[‘user’] = ‘user/login’;
$routes[‘login’] = ‘user/login’;
$routes[‘user/login’] = ‘user/login’;
$routes[‘user’] = ‘user’; //index function calls login function, so site.com/user takes me to login.
$routes[‘login’] = ‘user’;
$routes[‘user/login’] = ‘user’;

From the sources I could find, it seems like I have to use this kind of format:
Code:
$routes[‘user’] = ‘user/login’;

This does it work for me. I want to put the routes.php in my user module’s config directory, and go to site.com/login which will take me to site.com/user/login. I have done some checking and found that site.com/login is looking for a module called “login” which does not exist.

I am getting a 404 error, regardless of which combination I try above.

How can I make this work? Is this possible at all?

Regards,

Kobus

[eluser]Unknown[/eluser]
I recently had to do this so I thought I would post it in the hopes that someone can find it useful.

My goal was to make all models within any modules autoload when instantiated (but not before) by tying into PHP's spl_autoload functionality. HMVC already uses this to autoload MX classes as well as core and library classes, so I just added to that.

In the APP_ROOT/third_party/MX/Modules.php file you simply need to add the following to the autoload method which already exists there (the function starts on line 111).

Code:
/* autoload module classes */
  $module_path = str_replace('/'.SYSDIR, '' ,BASEPATH)."application/modules/";
  if($dir = opendir($module_path))
  {
   while(false !== ($current_dir = readdir($dir)))
   {
    if(is_file($location = APPPATH.'modules/' . $current_dir . '/models/' . strtolower($class).EXT)){
     include_once $location;
     return;
    }
   }
  }

This will work assuming your (relevant) directory layout is structured something like this (if your directory structure is slightly different, you can modify the paths/etc. in the above to match your case)
Code:
/ -
  - applications
    - modules
      - module_name
        - models
          - test_model.php
          - test2_model.php
      - module2_name
        - models
          - test_model.php

The end result is that I can do something like this in my controllers without having to do any call of include_once/require_once or $this->load, etc. and the models are included automatically when I call them (rather than either all in the beginning using the autoload array or manually).

Code:
// middle of some controller
function example() {
    // non-static method
    $test = new Test_Model();
    $test->do_something();

    // static method
    $test_data = Test2_Model::get_some_data();
}

Anyways, hope that helps someone.

[eluser]boytun[/eluser]
Hello
I get a big problem

when I run the module from my main mvc view I get a probleme:

Quote:A PHP Error was encountered
Severity: Notice

Message: Undefined property: Widg_html::$mdl_widg_html

Filename: controllers/widg_html.php

Line Number: 18


Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\application\modules\widg_html\controllers\widg_html.php on line 18

but when I run it directly form the url(localhost/widg_html) it works fun.

The name of my module is widg_html
This is the controller of the module:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Widg_html extends MX_Controller {

public function __construct()
{
  parent::__construct();

  $this->load->model('mdl_widg_html_page');
  $this->load->model('mdl_widg_html_widget');
  $this->load->model('mdl_widg_html');
}

public function index()
{
  $this->data['widget_body']=$this->mdl_widg_html->get();
  $this->load->view('display', $this->data[);
}

this is the model of the widget:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mdl_widg_html extends CI_Model {

public function __construct()
{
  parent::__construct();
  
}

public function get(){
  return $this->db->get('widg_html');
}

public function get_by($where, $single = FALSE)  
{
  $this->db->where($where);
  return $this->get(NULL, $single);
}

}

and this is how I load the module into the mvc view through my controller page
Code:
<?php echo Modules::run('widg_html') ; ?>

Thanks in advance

[eluser]wiredesignz[/eluser]
@boyfun,
Line Number 18 of your Widg_html controller (as shown) has no code that can cause an error.

[eluser]boytun[/eluser]
so, from your experience, what is, approximately, the cause of the probleme.
If you do not mind, I can send you a copy of my project.
As you can see everything is clear, I spent more than week searching to solve this probleme.
I am preparing my end of study project and the date of presentation will be very soon.
Need your help, please save me :/

[eluser]wiredesignz[/eluser]
[quote author="boytun" date="1366187463"]... I can send you a copy of my project...[/quote]

No thank you. I don't want your code You need to keep working on it yourself.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.