samdark / yii2-cookbook

Yii 2.0 Community Cookbook
1.45k stars 296 forks source link

New recipe #73

Closed mrsurname closed 8 years ago

mrsurname commented 8 years ago

About pretty URL and pagination

samdark commented 8 years ago

:+1:

mrsurname commented 8 years ago

Samdark, what is this? Preliminary estimation? :)

samdark commented 8 years ago

Yes. I like the idea.

mrsurname commented 8 years ago

Is it possible to use such rule:

'search-vuz/<page:\d+>/<per-page>' => 'site/search-vuz',

Problem is with dash symbol in parameter per-page This is a default URL parameter name for object to set pageSize property of yii\data\Pagination So my link is /search-vuz?page=2&per-page=9. In order to make it pretty I've changed default parameter name for ex. to n. And finally I've got a link search-vuz/2/9 with help of such rule

'search-vuz/<page:\d+>/<n>' => 'site/search-vuz',

Is it possible to avoid step with changing default parameter name and provide a dash as a part of parameter name?

samdark commented 8 years ago

Try escaping dash with \.

mrsurname commented 8 years ago

like this?

'search-vuz/<page:\d+>/<per\-page>' => 'site/search-vuz',

It doesn't work also

samdark commented 8 years ago

Then I have no idea. Need to dig into it.

mrsurname commented 8 years ago

What do you think? Is it ok to write a recipe about pagination + pretty url with instruction to change pageSize URL param name? When issue solved delete this instruction.

Also is it ok to create related issue?

samdark commented 8 years ago

Yep.

mrsurname commented 8 years ago

Another question :) Why pull request is still open? Because you have to check code before merging?

samdark commented 8 years ago

Yes. Code, wording etc.

samdark commented 8 years ago

Merged. Will adjust later.

samdark commented 8 years ago

Thank you!