Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC version 5.3

[eluser]Krzysiaczek[/eluser]
Hi wiredesignz, great extension.

I'm trying to call module from another place - a view like this:
Code:
<?php $parameter = 5; ?>
...
<?php echo Modules::run('samplemodule/samplemethod', $parameter); ?>
...
<?php echo $parameter;?>
I found that you are using in .../third_party/MX/Modules.php
Code:
call_user_func_array( callback $function , array $param_arr )
Based on info from php.net:
Quote:Referenced variables in param_arr are passed to the function by reference, regardless of whether the function expects the respective parameter to be passed by reference.
The problem is that I'm trying to change $parameter inside the module but when check back again in the view (from place where I've called that) it's not affected by changes inside module. It should be equal 6 but is still equal 5.
Code:
class Samplemodule extends MX_Controller {

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

function samplemethod($param) {
  ...
  $param++;
  ...
  return $output;
}

When try to force passing by reference in module definition it raises the error in MX/Modules
Code:
function samplemethod(&$param) {
Am I missing something?
:-S

[eluser]wiredesignz[/eluser]
In your example the method is being passed as a parameter, which is incorrect. Try something like this:
Code:
<?php echo modules::run('module/controller/method', $parameter); ?>

[eluser]Krzysiaczek[/eluser]
Sorry it was mistake trying to create dummy sample code. Originally my code is more complex, have more parameters, that's why I've made mistake editing this post but it doesn't change a thing. Sample code updated.

[eluser]Krzysiaczek[/eluser]
wiredesignz,
Could you please confirm if you can replicate the problem? if you find this weird? or perfectly normal?
Thanks in advance

[eluser]otherjohn[/eluser]
I am getting a unusual error. I am sure I haven't done something correct, but I can't figure out what it is?

I have in my main template, i pull a controller via <?php echo modules::run('navigation/navigation/web_admin_menu'); ?>

Code:
class Navigation extends MX_Controller {
    
    function __construct()
       {
            parent::__construct();
            
    }
    
    public function web_admin_menu()
    {      
            $this->load->library('acl');
            $data['acl'] = $this->acl;
            $this->load->view('navigation/web_admin_menu',$data);
    
    }
    
}

I get the following error when I try to load the page
Code:
ErrorException [ Notice ]: Undefined property: Navigation::$acl
APPPATH/modules/navigation/controllers/navigation.php [ 29 ]
24     public function web_admin_menu()
25     {      
26    
27        
28             @$this->load->library('acl');
29             $data['acl'] = $this->acl;
30             $this->load->view('navigation/web_admin_menu',$data);
31    
32     }
33    
34 }

[eluser]Krzysiaczek[/eluser]
Assuming that $this->acl should be initiated in the acl library, that's probably something wrong with that which is not visible as you have used quiet loading in previous line: @$this->load->library('acl');

[eluser]otherjohn[/eluser]
I thought that too, but if I remove $this->load->library('acl');
and in my view just call it, I get the same error but for the MODEL that is called from the library.

[eluser]Krzysiaczek[/eluser]
I'm not sure. If you remove this line loading 'acl' library where $this->acl should be taken from?
To make it work you should have either the method in your class called acl which returns something
e.g.
Code:
function acl(){
   ...
   return 125;
}

or the variable called acl inside the class

Code:
class Navigation extends MX_Controller {
    
    var acl;

    function __construct()
       {
            parent::__construct();
            $this->acl = 124;
       }
...etc.

Otherwise how can you expect $this->acl to work?

Do you have any errors related to loading that acl library?

Why do you use @ in front of the loader @$this->load->library('acl');?

[eluser]otherjohn[/eluser]
the @ is a misstype, but without it same results.

[eluser]Krzysiaczek[/eluser]
So if $this->acl should be coming from the acl library maybe you're missing something?
e.g.
If you load pagination you need to initialize it to make it work maybe the same here?

Have you try to load it and use it in normal controller?

Does HMVC make the difference?




Theme © iAndrew 2016 - Forum software by © MyBB