Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Showing pages that are published

Started by Claud Rusnac 9 years ago · 1 replies · 666 views
9 years ago

I have a template that is displaying a list of children, but the output also shows pages that are have "published: false".

TWIG
<ul class="list-group">
    {% for p in page.children if p != page %}
         <li class="list-group-item"> <a href="{{p.url}}"><i class="fa fa-angle-right" aria-hidden="true"></i> {{ p.title }}</a></li>
    {% endfor %}
</ul>

How do I exclude unpublished pages?

9 years ago

Hi
The page collection includes a "published" boolean so something like this should do what you need:

TWIG
{% if p.published %} 
{% endif %}
👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by complanar, 6 days ago
6 139 14 hours ago
Support · by Rick Beebe, 6 days ago
2 100 2 days ago
Support · by blu3prince, 3 days ago
0 50 3 days ago
Support · by alex, 4 days ago
2 92 3 days ago
Support · by Marcel, 2 weeks ago
1 143 4 days ago