Reputation: 39
I am working with kohana, because development goes so pretty fast. Now I want to achieve something which I can't really think of a workaround for.
What I want to achieve, there is a controller. It's called Controller_Restaurants
But those restaurants, are grouped by provinces and after province is clicked they are grouped by a city, and then a list of the restaurants is shown up.
All cities and provinces are already added to there specific database with fields.
I want to create a route in my controller. So can I achieve a following link:
domain/restaurants/province/city/restaurant-name
?
Or am I thinking like a douche and should I solve this otherwise?
Upvotes: 2
Views: 198
Reputation: 341
Build your routing like this:
Route::set('restaurants', 'restaurants(/<province>(/<city>(/<name>))))',
array(
'controller' => 'restaurants',
'action' => 'index',
));
It should work like this.
Upvotes: 2
Reputation: 6675
It is possible to create routes inside a controller in Kohana, but it won't help you solve your problem because routing has already happened.
What you need to do is create a route with optional parameters as suggested by @kingkero:
restaurants(/<province>(/<city>(/<name>)))
Then access the parameters in the URL from the controller like so:
$province = $this->request->param('province');
...
Upvotes: -1