MULTIPLE SUB-FOLDER LINK UP TO 2-3 SUBFOLDER IN CODEIGNITER

put this in your /application/core

NAME: MY_Router.php

set_directory($segments[0]);
$segments = array_slice($segments, 1);

/* ———– ADDED CODE ———— */

while(count($segments) > 0 && is_dir(APPPATH.’controllers/’.$this->directory.$segments[0]))
{
// Set the directory and remove it from the segment array
$this->set_directory($this->directory . $segments[0]);
$segments = array_slice($segments, 1);
}

/* ———– END ———— */

if (count($segments) > 0)
{
if ( ! file_exists(APPPATH.’controllers/’.$this->fetch_directory().$segments[0].EXT))
{
show_404($this->fetch_directory().$segments[0]);
}
}
else
{
$this->set_class($this->default_controller);
$this->set_method(‘index’);

if ( ! file_exists(APPPATH.’controllers/’.$this->fetch_directory().$this->default_controller.EXT))
{
$this->directory = ”;
return array();
}

}

return $segments;
}

show_404($segments[0]);
}
}

SOURCE: stackoverflow

SOURCE: http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/

FROM: http://ellislab.com/forums/viewthread/85554/

Advertisements
This entry was posted in CODE IGNITER. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s