Strike X Posted April 2, 2010 Share Posted April 2, 2010 I have developed basic MVC framework.. The routing does this at the moment: whatever.com/classname/action/value I wanted to create admin backend, I will need a subdirectory with new controller? url will need to look something like this: whatever.com/admin//classname/action/value Do you have any example of code how does subdirectory controller/routing work? Quote Link to comment Share on other sites More sharing options...
trq Posted April 2, 2010 Share Posted April 2, 2010 You would simply need to configure a base uri somewhere. If this then has a value of /admin, ignore admin within the uri. Of course, for what your actually doing it sounds like you need to also implement what some frameworks term modules[/m]. So the urls then become whatever.com/modulename//classname/action/value. This way you don't need to setup a new application within /admin, just make it a module of your main application. Quote Link to comment Share on other sites More sharing options...
Strike X Posted April 3, 2010 Author Share Posted April 3, 2010 You would simply need to configure a base uri somewhere. If this then has a value of /admin, ignore admin within the uri. Of course, for what your actually doing it sounds like you need to also implement what some frameworks term modules[/m]. So the urls then become whatever.com/modulename//classname/action/value. This way you don't need to setup a new application within /admin, just make it a module of your main application. I don't know modules mean for the MVC framework but I managed to get it working if controller file found in the sub directory. Here is example of code: $args = explode('/', $route); if (is_dir($this->pathfolder . $args[0])) { $this->pathfolder = $this->pathfolder . $args[0]; array_shift($args); } if (count($args) > 0) { if (file_exists($this->pathfolder . '/' . $args[0] . '.php')) { $this->controller = $args[0]; } else { // do something if not found. } } Is that ok? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.