Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI segment as page number in Pagination #1213

Merged
merged 11 commits into from
Oct 29, 2018

Conversation

nowackipawel
Copy link
Contributor

Description
Allows to pass URI segment as the page number to $pager->makeLinks().

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

links with the ``makeLinks()`` adding as a 5th parameter URI segment number, which contains page number.

<?= $pager->makeLinks($page, $perPage, $total, 'template_name', $segment) ?>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add additional detail showing what the uri would look like and how it would use the segment and I'm good with this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is still anything wrong? pls lemme know.

how uri will looks like + useful notes
how uri will looks like + useful notes
- set currentPage = 1 when declared segment is not exist:
i.e. http://domain.tld/user/index   - first page of list. 
- minor fix if ``only`` option is used
@nowackipawel
Copy link
Contributor Author

@lonnieezell could you check if everything is ok?

@jim-parry jim-parry added this to the 4.0.1? milestone Sep 27, 2018
@jim-parry
Copy link
Contributor

Your user guide writeup is awkward. Suggestion:

It is also possible to use a URI segment for the page number, instead of the page query parameter. Simply specify the segment number to use as the fifth parameter to makeLinks(). URIs generated by the pager would then look like https://domain.tld/model/[pageNumber] instead of https://domain.tld/model?page=[pageNumber].::

<?= $pager->makeLinks($page, $perPage, $total, 'template_name', $segment) ?>

Please note: $segment value can not be greater than the number of URI segments plus 1.

@lonnieezell lonnieezell merged commit e707342 into codeigniter4:develop Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants