Reputation: 397
I have a simple GET form which allows the user to type in a location, then select a couple of other options and perform a search.
So at the minute the url for this action is: controller/search?area=london&option1=whatever&option2=whateverelse
I'd like the url to be: controller/search/london?option1=whatever&option2=whateverelse
so in other words the GET param for the area would be incorporated into the url but not as a NVP.
Is there a way to do this? I'm a bit confused about routing or if there's another way?
Thanks
Upvotes: 0
Views: 386
Reputation: 25698
Use routing and the CakeDC search plugin. If you do not have yet read about routing you should do it, its a very powerful feature.
Route::connect('/search/:city/*', array('controller' => 'search', 'action' => 'index'), array('pass' => array('city'), 'city' => 'a-zA-Z0-9_-]+')));
Just wrote that down without testing, try it if does not work put some effort into it. This will make the city become the first arg of SearchController::index($city = null);
The search plugin will help you with mapping the query params to search conditions that can be used to retrieve the data from the database, see its readme.md how to do it.
Upvotes: 1