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

Get pagination object for any filtered collection #18

Open
fvsch opened this issue Apr 17, 2016 · 6 comments
Open

Get pagination object for any filtered collection #18

fvsch opened this issue Apr 17, 2016 · 6 comments

Comments

@fvsch
Copy link
Contributor

fvsch commented Apr 17, 2016

For an article index page that lists blog posts, I was using:

{% for article of page.collection %}
  {# Show link to article #}
{% endfor %}

{% include 'partials/pagination.html.twig' with {
  pagination: page.collection.params.pagination
} %}

But I needed to filter the collection by type because that page contains folders that are not articles. So I switched to:

{% set articles = page.collection.ofType('article') %}
{% for article of articles %}
  {# Show link to article #}
{% endfor %}

{% include 'partials/pagination.html.twig' with {
  pagination: articles.params.pagination
} %}

This work for the links, but not for the pagination which still sees the page count from page.collection().

Shouldn’t .params.pagination represent a pagination object for the collection it’s called from, rather than for the current page?

@flaviocopes flaviocopes self-assigned this Apr 18, 2016
@flaviocopes
Copy link
Contributor

This is a scenario that should work. Will test and make sure this works.

@flaviocopes
Copy link
Contributor

Thinking twice, I'm starting to think this is not actually expected to work, due to some issues.
First, which URL should the plugin redirect to, when clicking a "next" page?

This needs to work withing a collection page.

Would be solved by allowing filtering the type in the page collection itself, as per the other issue you opened.

@flaviocopes
Copy link
Contributor

Another issue was opened to allow such behavior #13 would gladly accept a PR that allows this functionality, provided there's a way to define the base route for the collection, maybe as a parameter to the twig include.

@fvsch
Copy link
Contributor Author

fvsch commented Apr 18, 2016

Thanks for your comments.

For the record the need for this scenario arose from limitations in collection filtering on the content side. I opened Grav bugs getgrav/grav#791 and getgrav/grav#792 on this topic.

It might still be worth to pursue #13 even with this two issues fixed, so I'll look into it later.

Flavio, maybe this issue could be closed as a duplicate of #13?

@flaviocopes
Copy link
Contributor

Let's leave this open too, so we have another request for this feat.

@Sogl
Copy link
Contributor

Sogl commented Oct 9, 2016

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants