Welcome Guest, Not a member yet? Register   Sign In
URL Rewriting: Name instead of ID
#2

[eluser]WanWizard[/eluser]
Exactly the same way as you do now.

I assume you have a controller called "authors" with a method called "show", that uses the parameter (the number) to lookup a record. So you can do:
Code:
if ( is_number($parameter) )
{
    $result = $this->author_model->get_by_id( $parameter );
}
else
    $result = $this->author_model->get_by_name ( $parameter );
}
If you want the URL to change, then you can do a redirect to the name after get_by_id() is succesful.


Messages In This Thread
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 04:50 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 05:03 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 05:05 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 05:05 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 07:20 AM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 06:41 PM
URL Rewriting: Name instead of ID - by El Forum - 07-20-2010, 07:25 PM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 01:16 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 05:57 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 06:00 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 06:08 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 06:11 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 07:54 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 07:58 AM
URL Rewriting: Name instead of ID - by El Forum - 07-21-2010, 12:25 PM
URL Rewriting: Name instead of ID - by El Forum - 07-26-2010, 10:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB