Welcome Guest, Not a member yet? Register   Sign In
Routing bug (is it a bug?)
#12

[eluser]ptrippett[/eluser]
Something simple along the lines of adding the how-to to the non-regex examples would suffice i feel, because the functionality is there its just not documented in all the right places and can be confusing if you lazy read like i do Smile

Code:
<h2>Examples</h2>

<p>Here are a few routing examples:</p>

<code>$route['journals'] = "blogs";</code>
<p>A URL containing the word "journals" in the first segment will be remapped to the "blogs" class.</p>

<code>$route['blog/joe'] = "blogs/users/34";</code>
<p>A URL containing the segments blog/joe will be remapped to the "blogs" class and the "users" method.  The ID will be set to "34".</p>

<code>$route['product/:any'] = "catalog/product_lookup";</code>
<p>A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the  "product_lookup" method.</p>

<code>$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";</code>
<p>A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.</p>

<p class="important"><strong>Important:</strong> Do not use leading/trailing slashes.</p>

I use this method for SEO optimization of links by: -

Code:
class Events extends Controller {

    function by_city_id($city_id, $city_name = '') {
        //Blah
    }
    
}


and then in routes.php: -

Code:
$route['city/(:num)/(:any)'] = "events/by_city_id/$1/$2";


and then creating a link to /city/1459/boston-massachusetts would execute Events::by_city_id(1459, 'boston-massachusetts'). You ignore the second value as it purely for SEO as you already have the correct city by its id from the first variable.


But whether thats worth including as example usage also is up for debate.


Messages In This Thread
Routing bug (is it a bug?) - by El Forum - 05-19-2008, 03:40 PM
Routing bug (is it a bug?) - by El Forum - 05-19-2008, 04:23 PM
Routing bug (is it a bug?) - by El Forum - 05-19-2008, 04:29 PM
Routing bug (is it a bug?) - by El Forum - 05-19-2008, 04:31 PM
Routing bug (is it a bug?) - by El Forum - 05-20-2008, 11:40 AM
Routing bug (is it a bug?) - by El Forum - 05-23-2008, 06:07 PM
Routing bug (is it a bug?) - by El Forum - 05-23-2008, 06:23 PM
Routing bug (is it a bug?) - by El Forum - 05-26-2008, 12:28 AM
Routing bug (is it a bug?) - by El Forum - 05-26-2008, 02:26 AM
Routing bug (is it a bug?) - by El Forum - 05-26-2008, 03:46 AM
Routing bug (is it a bug?) - by El Forum - 05-26-2008, 05:10 AM
Routing bug (is it a bug?) - by El Forum - 05-26-2008, 08:41 PM
Routing bug (is it a bug?) - by El Forum - 05-27-2008, 08:12 AM
Routing bug (is it a bug?) - by El Forum - 05-27-2008, 08:15 AM
Routing bug (is it a bug?) - by El Forum - 05-27-2008, 01:49 PM
Routing bug (is it a bug?) - by El Forum - 05-27-2008, 03:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB