shaho
(shaho)
1
I’m trying to make my pagination and sorting in the url more friendly looking. currently my url looks like this
https://bla.com/user/dashboard/?page=3&sort=created_at
how do i make it look like this
https//bla.com/user/dashboard/page/3/sort/created_at
or
https//bla.com/user/dashboard/page/3/sort/date
(to hide my column name)
currently i have this in my main.php
just for page
'user/dashboard/page/<page:\d+>' => 'user/dashboard'
but this doesn’t work. Thanks
tri
(tri - Tommy Riboe)
2
'rules' => [
[
'pattern' => '/user/dashboard/<page:\d+>/<sort:\w+>',
'route' => 'user/dashboard',
'defaults' => ['page' => 1, 'sort' => ''],
],
shaho
(shaho)
3
thanks. It kind of works tho. when i sort it and click on pagination it works. but when i sort is back to default i get a 404
when i sort i get this
https://bla.com/frontend/web/user/dashboard/report_type/
when i unsort the link is
https://bla.com/frontend/web/user/dashboard/?page=1&sort=-report_type&_pjax=%23pjax-reports
tri
(tri - Tommy Riboe)
4
Change this row
‘pattern’ => ‘/user/dashboard/page:\d+/sort:[\w\-]+’,
(this will accept a hyphen)
tri
(tri - Tommy Riboe)
5
Sorry for the confusion. I changed the pattern to your controller/action.