I see that in the documentation, collections can be filtered by published
or nonPublished
. However, I cannot figure out how to include unpublished pages in the first place, and so my collections always end up empty (I want to display titles of upcoming posts with their scheduled publish date).
Is there a way I can include non-published pages in my collection query, either in the header or using Twig? Thanks!
hi @psrankin
you have a method Collection::nonPublished()
- Filters the current collection to include only non-published pages
https://learn.getgrav.org/content/collections#multiple-collections
I will do like this :
{% for p in page.find('/blog').children.nonpublished('01/01/2014', '01/01/2019').order('date', 'desc') %}
{{ p.title }}
{{ p.date|date("d-m-y") }}
{% endfor %}
non tested
I think it will do the job !
Thanks, that worked! I appreciate your help.
glad it works
Could you please mark as solved, thanks
The solved checkbox isn’t showing up for me yet (I’m new to Discourse). I assume it has a delay before allowing an answer to be marked as resolved, so I’ll check back later. Thanks again!
Thanks for your solution. I still don’t see the “solved” checkbox that I’m expecting and can’t seem to find any other way to mark your post as the solution. Is something wrong with my account?