Comments (4)
Per the readme: https://github.com/getgrav/grav-plugin-pagination#twig-pagination-function
a quick example here:
{% set options = { items: {'@root.descendants':''}, 'order': {'by': 'folder', 'dir': 'asc'}} %}
{% set my_collection = page.collection(options) %}
{% do paginate( my_collection, 5 ) %}
{% for p in my_collection %}
<ul>
{% if page.slug == p.slug %}
<li class="{{ p.slug }} active"><span>{{ p.menu }}</span></li>
{% else %}
<li class="{{ p.slug }}"><a href="{{ p.url }}">{{ p.menu }}</a></li>
{% endif %}
</ul>
{% endfor %}
{% include 'partials/pagination.html.twig' with {'base_url':page.url, 'pagination':my_collection.params.pagination} %}
from grav-plugin-pagination.
Coincidentally, I dealt with this a few weeks ago. I confirm this behavior, which also surprised me. The direct insertion into the frontmatter solved the problem.
However, I would also welcome a collection
solution that would be universal for all pages using the twig template (e.g. blog, news, etc.).
from grav-plugin-pagination.
Thanks, @rhukster.
From: https://learn.getgrav.org/16/content/collections#advanced-collections
{% set options = { items: {'@page.children': '/my/pages'}, 'limit': 5, 'order': {'by': 'date', 'dir': 'desc'}, 'pagination': true } %}
{% set my_collection = page.collection(options) %}
I guess the limit and pagination option at the end of the first line is what threw me under the bus there. Why is it listed if it has no effect?
from grav-plugin-pagination.
The example on https://learn.getgrav.org does not contain the code needed for pagination:
```
...
{% do paginate( my_collection, 5 ) %}
```
But this is described in detail in the README.md
of plugin. I will send Pull request with the addition of code.
The example by @rhukster on https://github.com/getgrav/grav-plugin-pagination#twig-pagination-function contain the full code needed for pagination and is described in detail in the README.md
of plugin too.
from grav-plugin-pagination.
Related Issues (20)
- wrong pagination HOT 1
- grav pagination can't see feature page data HOT 1
- CSS missing with {% do paginate() %} HOT 6
- Pagination doesn't work in an embeded page HOT 2
- Show only a subset of pages in pagination ul. HOT 1
- Plugin ignore twig syntax 'pagination':true
- Where does $uri->currentPage() come from? HOT 2
- Builtin css only works when header.pagination is set to true HOT 1
- Query parameters cleared by pagination HOT 2
- Pagination does not disappear if no pagination is required. HOT 1
- Install fails from within backend
- Using pagination breaks isFirst/isLast and siblings calculations HOT 2
- Enhancement request: ability to remove ":" from URL
- Change ":" to "-" or "/" in pagination url HOT 1
- Lists of collections on pages with the page parameter are not displayed HOT 1
- Limit word number
- Rendered pagination exceeds page width HOT 2
- Error 404 due to removal of protocol slash
- Since update to v1.4.5 today, pagination broken, shows https://page:2/ HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grav-plugin-pagination.