Welcome Guest, Not a member yet? Register   Sign In
MVC and URLs
#7

[eluser]Colin Williams[/eluser]
Routing is good but can be less flexible than employing a _remap() method in the controller. Consider this (which I do often):

Code:
class Users extends Controller {

    function _remap($request)
    {
        if (is_numeric($request))
        {
            $this->get_user($request);
        }
        else if (method_exists($this, $request))
        {
            $this->$request($this->uri->rsegment(3), $this->uri->rsegment(4));
        }
        else
        {
            show_404();
        }
    }
  
    function get_user()
    {
        // This is now called when you encounter a URL like /users/23
    }
}


Messages In This Thread
MVC and URLs - by El Forum - 11-09-2008, 03:03 PM
MVC and URLs - by El Forum - 11-09-2008, 05:56 PM
MVC and URLs - by El Forum - 11-09-2008, 06:45 PM
MVC and URLs - by El Forum - 11-09-2008, 07:01 PM
MVC and URLs - by El Forum - 11-09-2008, 07:30 PM
MVC and URLs - by El Forum - 11-09-2008, 07:46 PM
MVC and URLs - by El Forum - 11-09-2008, 09:45 PM
MVC and URLs - by El Forum - 11-10-2008, 01:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB