Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Version 4.3

[eluser]Maxximus[/eluser]
4.1 is currently a bit slower than 4.0, and uses a bit more memory. What could speed things up is replacing the modules::find() function with a registry-array in a temp file.

I know, in development you will have the need to rebuild this file regularly, but once in production it will sit for quite some time, saving a lot of processor cycles.

[eluser]wiredesignz[/eluser]
Thanks Maxx, I am looking at somthing like that right now.

4.1.11, will be ready soon and has some speed and memory improvements also.

Refactoring code is the biggest improvement.

[eluser]wiredesignz[/eluser]
Version 4.1.11 of Modular Extensions is available on the wiki.

Serious speed improvements and lower memory usage.

My test site with profiler on: http://www.ezybuycars.net.nz/home

Using a module to render the Search partial and Page controller modules, with Help a method controller and an Error module controller.

[eluser]Maxximus[/eluser]
Okay cool. Already getting closer to 4.0!

4.0.30: mem: 955K, base: 109 ms, controller: 676 ms
4.1.11: mem: 1149K base: 164 ms, controller: 714 ms

This is with: CL_Auth, sessions, 7 view partials in module, 1 modules::run() in view (7 calls).

[eluser]Maxximus[/eluser]
[4.1.11] Currently using modules::run() in a controller requires the called method to use a
Code:
return $this->load->view($partial, $data, TRUE);
To be able to use the called method stand-alone will require extra handling (need to echo the returned value somewhere else), and there is no way to use existing/older controller/methods as a partial this way.

Okay, you can use this:
Code:
ob_start();
modules::run($module, $data, $method);
$data[$method] = ob_get_contents();
ob_end_clean();
but it would be great to be able to set this in modules::run(). Perhaps similar to load->view?
Code:
$data[$method] = modules::run($module, $data, $method, TRUE);
This works in modules_helper:
Code:
function run($module, $data = '', $method = '', $buffer = FALSE)
{
    if($class =& modules::load($module))
    {
        if ($method == '' OR $method == $module) $method = 'index';
        if ($buffer === FALSE) {
           return (method_exists($class, $method)) ? $class->$method($data) : $class->_error($method, $data);
        } else {
           ob_start();
           (method_exists($class, $method)) ? $class->$method($data) : $class->_error($method, $data);
           $return = ob_get_contents();
           ob_end_clean();
           return $return;
        }
     }

    show_error("Unable to locate the requested module: ".$module);
}

[eluser]wiredesignz[/eluser]
Thanks Maxx, Try this. (untested)
Code:
//modules_helper.php
    
    function run($module, $data = '', $method = '', $return = FALSE)
    {
        if($class =& modules_load($module))
        {
            if ($method == '' OR $method == $module) $method = 'index';

            ob_start();
            
            $output = (method_exists($class, $method)) ? $class->$method($data) : $class->_error($method, $data);
        
            if ($return === FALSE) $output = ob_get_contents();
            
            ob_end_clean();
            
            return $output;
        }

        show_error("Unable to run the requested module/method: ".$module.'->'.$method);
    }

[eluser]Maxximus[/eluser]
No didn't give the expected results (blank partials). Probably because the $output will not be filled (module output is echoed, and not catched by $output), and after that the output is destroyed.

[eluser]wiredesignz[/eluser]
I'm pretty sure anything echoed while output buffering is active should be caught and passed to $output. Check your TRUE/FALSE return values on load->view and modules::run.

[eluser]Maxximus[/eluser]
True, my bad. Did not use 'echo' in the view.

[eluser]wiredesignz[/eluser]
Version 4.1.16 of Modular Extensions will be available on the wiki today.

Added feature to autoload controllers.




Theme © iAndrew 2016 - Forum software by © MyBB