Routes, how to handle empty strings? [SOLVED, with hack] |
[eluser]nuwanda[/eluser]
[quote author="xzela" date="1279925214"] When a user goes to the URI http://localhost/pages/cake-types I want to show the user a list of cake types. However, when the user goes to the URI http://localhost/pages/cake-types/cupcakes it should the appropriate page (a page related to cupcakes). [/quote] Hmmm, this is one of those times when you wonder if you're reading the question correctly. No routes required. You have a controller, say Cakes, with a method of cake_types. If no cake type is specified, show all cakes, else show the cake type requested. Sample URIs: http://www.houseofcakes/cakes/cake_type //shows all cakes http://www.houseofcakes/cakes/cake_type/cupcakes //shows cupcakes Code: class Cakes extends Controller{ No? And if you called the cake_type method in the index method, you could also use the URI http://www.houseofcakes/cakes //shows all cakes because it calls the cake_type method without argument Code: <?php |
Messages In This Thread |
Routes, how to handle empty strings? [SOLVED, with hack] - by El Forum - 07-23-2010, 11:46 AM
Routes, how to handle empty strings? [SOLVED, with hack] - by El Forum - 07-23-2010, 11:59 AM
Routes, how to handle empty strings? [SOLVED, with hack] - by El Forum - 07-23-2010, 12:19 PM
Routes, how to handle empty strings? [SOLVED, with hack] - by El Forum - 07-23-2010, 12:35 PM
Routes, how to handle empty strings? [SOLVED, with hack] - by El Forum - 07-23-2010, 08:14 PM
|