Welcome Guest, Not a member yet? Register   Sign In
Nested sub-controller folder/directory AND using a3m marshmallow module PLEASE, NEED HELP!!!
#1

[eluser]boltsabre[/eluser]
Hi guys,

Been trying for hours to be able to use sub directories in my controllers, found lots of information, but couldn't get it to work.
(example solution: http://ellislab.com/forums/viewthread/202176/)

I realised that it's because I'm using the a3m marshmallow module, which is already extending the CI_Router class.

Does anyone know how I can use controller sub-dir's AND a3m marshallow? Sorry if it's a stupid question, I've been up all night working to a deadline I'm having a brain fade (my OOP isn't great) :-(

a3m already has extended the core Router class as such:
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX_Router class */
require APPPATH."third_party/MX/Router.php";
class MY_Router extends MX_Router {}

Which is extending upon:
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX core module class */
require dirname(__FILE__).'/Modules.php';

class MX_Router extends CI_Router
{
private $module;

public function fetch_module() {
  return $this->module;
}

public function _validate_request($segments) {  
  
  /* locate module controller */
  if ($located = $this->locate($segments)) return $located;
  
  /* use a default 404_override controller */
  if (isset($this->routes['404_override']) AND $segments = explode('/', $this->routes['404_override'])) {
   if ($located = $this->locate($segments)) return $located;
  }
  
  /* no controller found */
  show_404();
}

/** Locate the controller **/
public function locate($segments) {  
  
  $this->module = '';
  $this->directory = '';
  $ext = $this->config->item('controller_suffix').EXT;
  
  /* use module route if available */
  if (isset($segments[0]) AND $routes = Modules::parse_routes($segments[0], implode('/', $segments))) {
   $segments = $routes;
  }

  /* get the segments array elements */
  list($module, $directory, $controller) = array_pad($segments, 3, NULL);

  foreach (Modules::$locations as $location => $offset) {
  
   /* module exists? */
   if (is_dir($source = $location.$module.'/controllers/')) {
    
    $this->module = $module;
    $this->directory = $offset.$module.'/controllers/';
    
    /* module sub-controller exists? */
    if($directory AND is_file($source.$directory.$ext)) {
     return array_slice($segments, 1);
    }
    
    /* module sub-directory exists? */
    if($directory AND is_dir($module_subdir = $source.$directory.'/')) {
      
     $this->directory .= $directory.'/';

     /* module sub-directory controller exists? */
     if(is_file($module_subdir.$directory.$ext)) {
      return array_slice($segments, 1);
     }
    
     /* module sub-directory sub-controller exists? */
     if($controller AND is_file($module_subdir.$controller.$ext)) {
      return array_slice($segments, 2);
     }
    }
  
    /* module controller exists? */  
    if(is_file($source.$module.$ext)) {
     return $segments;
    }
   }
  }
  
  /* application controller exists? */  
  if(is_file(APPPATH.'controllers/'.$module.$ext)) {
   return $segments;
  }
  
  /* application sub-directory controller exists? */
  if(is_file(APPPATH.'controllers/'.$module.'/'.$directory.$ext)) {
   $this->directory = $module.'/';
   return array_slice($segments, 1);
  }
}

public function set_class($class) {
  $this->class = $class.$this->config->item('controller_suffix');
}
}

If anyone has a fix for this I'd be extremely greatful!!!


Messages In This Thread
Nested sub-controller folder/directory AND using a3m marshmallow module PLEASE, NEED HELP!!! - by El Forum - 06-02-2012, 07:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB