Comments (7)
Quite old issue but in case someone reads it searching for a solution:
I handle this issue by declaring a second collection (named "unpaginated") in the frontmatter like seen here and using it to access the full length like here. It's not beautiful but it delivers the results I need.
from grav-plugin-pagination.
pagination in twig is not really the best way, i think actually this is something to look at in the Collection class itself, within the Grav core. I'm surprised there isn't a method already. I'll have to have a look.
from grav-plugin-pagination.
@rhukster since I am actively using grav and would like to use pagination and get the total number of articles … I would like to ask if there has been any progress yet?! Don't want to stress, though.
from grav-plugin-pagination.
I would also appreciate a way to get the size of a collection without hacking around.
from grav-plugin-pagination.
We recenrly ran into this issue. As of version 1.6.25, this is still not fully solved. If there are others who would like to have access to this via twig, I am contemplating writing something in order to use a twig statement like:
{% page.collection | raw_length %}
To provide the actually length of self.siblings prior to pagination.
Or, has this been solved and we have missed it? If so, any help is appreciated. We are fairly new to Grav (and LOVE it).
from grav-plugin-pagination.
Found another solution that seems to work well and wanted to share here
Background:
We have a page using the blog twig template, several subpages (posts) using the item twig template. We wanted to use pagination with a snippet of text that says "Showing page X of Y".
Since the pagination limit was set at 3, we could not get this to print "Showing 3 of 4" since
{{ page.collection | length }}
only returns the current page. To solve it, we added this to the front matter:
content:
items: '@self.children'
limit: '3'
order:
by: date
dir: asc
pagination: true
unpaginated:
items: @self.children
filter:
published: true
and then used this code in the twig of the parent page using the blog template in the pagination.html.twig file:
<li class="page-item disabled">
{# See issue https://github.com/getgrav/grav-plugin-pagination/issues/29 #}
{% set fullsize = page.header.unpaginated ? page.collection('unpaginated') : page.collection %}
<span class="page-link" aria-hidden="true">Showing {{ page.collection | length }} of {{
fullsize|length }} properties</span>
<span class="sr-only">Previous</span>
Here is the output:
from grav-plugin-pagination.
It's 2021 now. Is there really no better solution as of yet?
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 option not respected when added to a collection in twig HOT 4
- 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.