Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Showing pages that are published

Started by Claud Rusnac 9 years ago · 1 replies · 638 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 JakobDB, 17 hours ago
1 29 8 hours ago
Support · by ramenos, 2 days ago
3 56 13 hours ago
Support · by gravinator, 7 days ago
3 191 2 days ago
Support · by Roger Parkinson, 1 week ago
3 284 6 days ago
Support · by Marcel, 2 weeks ago
4 235 1 week ago