[eluser]Gnative[/eluser]
I often have the need to return data from a module if the module exists.. so I've added these to functions
public static function exists($module){
return method_exists($module, 'index');
}
/**
* Run a module controller method
* Output from module returned.
**/
public static function data($location)
{
$method = 'index';
if(substr_count($location, '/') == 2 AND $pos = strrpos($location, '/'))
{
$method = substr($location, $pos + 1);
$location = substr($location, 0, $pos);
}
if($class = self::load($location))
{
if ( ! method_exists($class, $method))
show_error("Unable to run the module: {$location}/{$method}");
$args = func_get_args();
return call_user_func_array(array($class, $method), array_slice($args, 1));
}
}