Fix collection retrieval#28
Conversation
|
I noticed this while trying to use the archive plugin with an |
|
@rhukster Can you take a look? |
| } | ||
| if ($new_approach) { | ||
| $collection = $page->children(); | ||
| $collection = $page->collection(); |
There was a problem hiding this comment.
collection() alone is not enough. pagination in the collection definition will cause only the first page of results to be taken into account for the archives.
There was a problem hiding this comment.
Thanks for the review, I'll revisit this PR when I have some free time (probably next week) and check if disabling pagination works!
There was a problem hiding this comment.
Disabled pagination in latest version, seems to be working as intended 👌
`children()` only retrieves direct children, as per the code: https://github.com/getgrav/grav/blob/1.6.27/system/src/Grav/Common/Page/Page.php#L2422 `collection()` is the proper retrieval method: https://github.com/getgrav/grav/blob/1.6.27/system/src/Grav/Common/Page/Page.php#L2675 This can be confirmed by looking at what's used for collection operations (e.g. `isFirst()` or `isLast()`): https://github.com/getgrav/grav/blob/1.6.27/system/src/Grav/Common/Page/Page.php#L2439
b881279 to
b6add10
Compare
|
Bumping this -- don't hesitate to HMU if I can do anything. |
|
@rhukster Revisiting old PRs -- is there anything I can do to get this across the finish line? |
|
I have this issue in a list to review when i get a chance. Need to test to ensure backwards compatibility as it is changing a behavior that users might rely on. |
children()only retrieves direct children, as per the code:https://github.com/getgrav/grav/blob/1.6.27/system/src/Grav/Common/Page/Page.php#L2422
collection()is the proper retrieval method:https://github.com/getgrav/grav/blob/1.6.27/system/src/Grav/Common/Page/Page.php#L2675
This can be confirmed by looking at what's used in default Quark theme when retrieving collection blog page template:
https://github.com/getgrav/grav-theme-quark/blob/2.0.3/templates/blog.html.twig#L3