Reputation: 1559
I have following route in my module config:
/home[/:action][/:id][/:page][/:service][/:sort]
When I try to skip some params, like page and/or service, and just pass sort variable, it is beeing set as page. That route works perfecly fine:
home/index/1/1
and I get:
action = index
page = 1
service = 1
but when I skip some params, and want only pass action and sort:
home/index/asc
I get:
action = index
page = asc
I create my link like this:
$this->url(null, array('sort' => $sort), array(), true);
Is there any proper way to do it correctly and as I want?
In ZF that was much easier, because it was url like: index/sort/asc etc. key of param and it's value. Is it possible to achieve in ZF2?
Upvotes: 0
Views: 249
Reputation: 5371
when using optional params in route they need to have a name or be inclosed inside another optional param :
'/home[/:action[/id/:id][/page/:page][/service/:service][/sort/:sort]]'
Upvotes: 2