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

[eluser]dpgtfc[/eluser]
I don't know if this has come up, but if I load the pagination class in a controller, I get an error (displayed at end of the post). Also, there is no longer support for controllers being in sub-directories. Is that intended? I have some of my controllers in controllers/site/controller1.php and I get a page not found error.


Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined index: pagination

Filename: libraries/Controller.php

Line Number: 321

Fatal error: Cannot access empty property in /system/application/libraries/Controller.php on line 323

[eluser]wiredesignz[/eluser]
Quote:...if I load the pagination class in a controller, I get an error (displayed at end of the post)...
... no longer support for controllers being in sub-directories. Is that intended?

Loading the pagination library works without error here. Try again.

Controller sub directories are replaced by modules in when using Modular Extensions.

[eluser]BDT[/eluser]
@wiredesignz: thanx for your previous reply, i solved the problem (MY_Loader constructor)

Another question:

in 4.2.06 modules_helper have this:
run($module, $data = '', $method = '')
in my system i call this: modules::run($ModulAdm, $MethodData, 'GetInfoForRelatedContentEdition')

but now (5.1.39) modules::run only for view...
how can i call module method from another module when method is in module/method dir, filename the method name and classname is the same as method name?

Write function in my_loader, load method from module/method dir and return with passed data?

[eluser]wiredesignz[/eluser]
[quote author="BDT" date="1227288648"]
...but now (5.1.39) modules::run only for view... [/quote]

Try one of the following:
Code:
$data = modules::load($ModulAdm)->GetInfoForRelatedContentEdition($MethodData);

//or

$data = $this->load->module($ModulAdm)->GetInfoForRelatedContentEdition($MethodData);

//or

$Modul = $this->load->module($ModulAdm);
$data = $Modul->GetInfoForRelatedContentEdition($MethodData);

[eluser]BDT[/eluser]
not work, Call to undefined method pagesadmin::GetInfoForRelatedContentEdition()
:-S

I need fast solution for this, and now i write runmethod function (for testing) in Modules.php based your run function and this work:


Code:
public static function runmethod($module, $data = '', $method = '')
    {
        if($class =& Modules::load($module))
        {
            /* protect the constructor */
            ($method == '' OR $method == $module) AND $method = 'index';
            if(method_exists($module,$method)){
            ob_start();

            $output = $class->method($method, $data);

            $buffer = ob_get_contents();

            ob_end_clean();

            return ($output) ? $output : $buffer;
            }else{

                list($path, $file) = modules::find($method, $module, 'methods/');
                if(empty($path)){
                    show_error("Unable to find the module method file in module/methods dir: $module/methods/$method".EXT);
                }else{
                    require_once($path.$file.EXT);
                
                    ob_start();
                    $LoadedMethodClass = new $method();
                    $output = $LoadedMethodClass->index($data);

                    $buffer = ob_get_contents();

                    ob_end_clean();
                    return ($output) ? $output : $buffer;
                }
            }
        }
    }

[eluser]wiredesignz[/eluser]
@BDT, Apologies I did not understand your question properly.

Loading module/method class files is deprectaed in ME 5.1 so writing your own loader is the only option.

Good luck.

[eluser]BDT[/eluser]
Fortunately my updated system work again.

I put class_exist check:

Code:
public static function runmethod($module, $data = '', $method = '')
    {
        if($class =& Modules::load($module))
        {
            /* protect the constructor */
            ($method == '' OR $method == $module) AND $method = 'index';
            if(method_exists($module,$method)){
            ob_start();

            $output = $class->method($method, $data);

            $buffer = ob_get_contents();

            ob_end_clean();

            return ($output) ? $output : $buffer;
            }else{

                list($path, $file) = modules::find($method, $module, 'methods/');
                if(empty($path)){
                    show_error("Unable to find the module method file in module/methods dir: $module/methods/$method".EXT);
                }else{
                    if(!class_exists($method)){
                        require_once($path.$file.EXT);
                        $LoadedMethodClass = new $method();
                    }else{
                        $LoadedMethodClass = &new;$method();
                    }
                    
                    ob_start();
                    
                    $output = $LoadedMethodClass->index($data);

                    $buffer = ob_get_contents();

                    ob_end_clean();
                    return ($output) ? $output : $buffer;
                }
            }
        }
    }

[eluser]BDT[/eluser]
Ohh wiredesignz, sorry my bad english 8-/

[eluser]BDT[/eluser]
if anyone use this, remove ; from inside &new;$method();

(forum post bug?)

[eluser]wiredesignz[/eluser]
Tip:

PHP5 Objects are assigned by reference so & is not required at all.

Use & when you need to obtain reference to a non object variable.




Theme © iAndrew 2016 - Forum software by © MyBB