A
A
AndreyAndreevTM2017-01-17 22:21:44
Yii
AndreyAndreevTM, 2017-01-17 22:21:44

How to configure Yii2 routing for search (search) / pagination?

The following rules are included:

'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller>' => '<controller>',

1) When using search, the address bar looks like this:
http://localhost/?ProductSearch%5Bcategory%5D=&ProductSearch%5Bcategory%5D%5B%5D=1&ProductSearch%5Bcategory%5D%5B%5D=2&ProductSearch%5Bprice_start%5D=&ProductSearch%5Bprice_end%5D=

I wanted to bring it to the form: localhost/search/param1=value1; param2=value2 or something similar.
2) When using pagination:
http://localhost/?page=2&per-page=5

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AndreyAndreevTM, 2017-01-18
@AndreyAndreevTM

Found the answer here:
yiiframework.ru/forum/viewtopic.php?t=30274

M
Maxim Timofeev, 2017-01-18
@webinar

semicolon - not allowed. In the search, the number of parameters is not known, so the rule can be made, but then you have to change the logic in a bunch of places, replacing it with crutches. For what? The search result should not be CNC this is normal. But if it itches a lot, it's easier to switch from GET to POST

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question