Closed nbusseneau closed 3 years ago
One solution is to disable pagination when retrieving page collection from Twig, by passing false
as second parameter:
{% set blog_collection = page.find(header_var('blog_url')|defined(theme_var('blog-page'))).collection('content', false) %}
I'll be closing this and instead propose a PR in default Quark theme for handling this scenario, since pagination is built into Quark by default but does not handle this case.
Actually, Quark handles this properly because it uses Page::nextSibling()
and Page::prevSibling()
, which themselves use Page::adjacentSibling($direction)
, which uses an unpaginated collection: https://github.com/getgrav/grav/blob/d4a20c71c2dadf7c843a170975a8161b7f5ce191/system/src/Grav/Common/Page/Page.php#L2490-L2499
The reason I was in need of retrieving collection directly and then using collection-level functions is because I am using a collection with @self.descendants
due to my folder structure looking like this:
├───2019
│ ├───11
│ │ ├───foo
│ │ └───bar
│ └───12
│ └───baz
└───2020
└───01
└───qux
This does not play well Page::adjacentSibling($direction)
since it is based on direct parent collection: $parent->collection('content', false)
Not sure something can nor needs to be done here, I don't think there's a way for a Page
to know about its containing collection as it could be in multiple, hence using the direct parent (containing folder) as basis for Page
siblings looks rather sound to me. Websites using the Quark theme with another folder structure just have to adapt the template, as did I.
Hi,
Using pagination breaks theme usage of all of the following functions:
Collection::isFirst($path)
Collection::isLast($path)
Collection::prevSibling($path)
Collection::nextSibling($path)
Noticed this because it breaks sibling links in themes:
Obviously, this happens because the collection on which the functions operate is the paginated version, instead of the source collection.
I'll be poking around with the intent of PRing a solution (either here or in Grav core I guess), hints are appreciated.