Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - (HMVC) - Version 3.1.9
#71

[eluser]sikkle[/eluser]
so with that what will i call in my "standard" view to call this module ?

thanks a lot for your time really.
#72

[eluser]wiredesignz[/eluser]
from your view:
Code:
<?php echo modules::run('find_last10') ?>
#73

[eluser]Avatar[/eluser]
wiredesignz,

thank you for this great library addition to ci. I have been trying it out and in my test I have found that I had to modify the run function call. Please see below.
Code:
function run($module, $data = '', $method = 'index')
    {
        $class =& modules::load($module);
        if(function_exists($class->$method($data)))
        return $class->$method($data);
        else
        return $class->index($data);
    }
notice I've add a check to see if the modules function exists otherwise it will call index function of that module. I also have a question. How would I dynamically create a module in directory structure if it doesn't already exist?
Does the ci community think that would be a worth while addition to this library? I have some other addition I will submit later, just slipped my mind at the moment. I will do more testing. Thank you.
#74

[eluser]Avatar[/eluser]
Actually the above still doesn't fix this bug. Will do more testing. Is there any way for me to find out which is the current active module that code is running in? Basically, what is the active module?
#75

[eluser]wiredesignz[/eluser]
Every module is created with an index method, so your alteration is not required.
Code:
class Module
{
    function Module()
    {
        $ci =& get_instance();
        
        $this->load =& new Loader($this);
        $this->load->_assign_libraries($this, $ci);
        $this->load->_ci_assign_to_models();
        
        log_message('debug', ucfirst(get_class($this))." module initialised");
    }
    
    function index()
    {
        log_message('error', ucfirst(get_class($this))." module: No index method defined");
    }
}

I don't understand why you need to see which module is running but you can use: get_class($this) inside the module to get its class name.
#76

[eluser]Avatar[/eluser]
yes, I understand. I combining this library with smarty and in my project I can't think of any other way but to call module functions. But for that to work there needs to be validation that that function exists in the module instead of spitting out an error call index function. when running this function, I get the error below.
FUNCTION:
Code:
function run($module, $data = '', $method = 'index')
    {
        $class =& modules::load($module);
        if(function_exists($class->$method))
        return $class->$method($data);
        else
        return $class->index($data);
    }
ERROR:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: User::$stuff

Filename: helpers/modules_helper.php

Line Number: 102
it checks for a variable in that module calss but it doesn't exist because it's a function.
and if with previous code function_exists($class->$method($data))
it just calls index, disregarding the function call altogether, kinda. Need professional assistance Smile TIA;
#77

[eluser]wiredesignz[/eluser]
Try this:
Code:
function run($module, $data = '', $method ='index')
{
    $class =& modules::load($module);
    return (method_exists($class, $method))? $class->$method($data) : $class->index($data);
}
#78

[eluser]Avatar[/eluser]
Thank you for fast reply. But it's still doing it, same error.
#79

[eluser]Avatar[/eluser]
something inside function_exists with the $method it doesn't like
#80

[eluser]wiredesignz[/eluser]
Check the edit above Smile

use method_exists($class, $method)

I will add this to the helper in 4.0.3 Thanks Wink




Theme © iAndrew 2016 - Forum software by © MyBB