johan
February 12, 2020, 4:17pm
1
Hi,
Moved all pages under “listed” to “unlisted” but below code won’t go to <?php snippet('empty') ?>
.
<?php if ($page->listed()->hasPages()): ?>
<?php if ($page->layout()->value() === 'grid'): ?>
<?php snippet('posts-grid') ?>
<?php else: ?>
<?php snippet('posts-list') ?>
<?php endif ?>
<?php else: ?>
<?php snippet('empty') ?>
<?php endif ?>
Tried with isNotEmpty()
instead of hasPages()
but then when there are pages under “listed” nothing is shown
texnixe
February 12, 2020, 4:32pm
2
There is no $page->listed()
method. What is that line supposed to do?
johan
February 12, 2020, 4:45pm
3
This is the blueprint:
tabs:
posts:
columns:
- width: 1/3
sections:
drafts:
extends: sections/posts
headline: Drafts
image: page.cover.toFile
status: draft
unlisted:
extends: sections/posts
headline: Unlisted
image: page.cover.toFile
status: unlisted
- width: 2/3
sections:
listed:
extends: sections/posts
headline: Published
image:
cover: true
query: page.cover.toFile
ratio: 2/1
layout: cards
status: listed
If there are posts with status “listed” I’m listing those posts on that page. Otherwise I’m showing a message that tells there are no posts.
texnixe
February 12, 2020, 4:48pm
4
Yes, but a section cannot be called from the content, because it’s not stored in the file. Call the page’s children and filter by listed
: $page->listedChildren()
or
if ($page->hasListedChildren()){
// do stuff
}
1 Like
johan
February 12, 2020, 5:15pm
5
Thanks so much as always!