Hello folks,
I tried to follow the sample for the ‘one pager’: One pager | Kirby CMS
I am able to build the templates and blueprints. Except of the /site/templates/one-page.php template. When I tried the code as in the example it doesn’t work. My ‘parts’ (sub-pages?) doesn’t show up.
<main>
<?php foreach ($page->children()->listed() as $part) : ?>
<section class="<?= $part->intendedTemplate() ?>">
<?php snippet($part->intendedTemplate(), compact('part')) ?>
</section>
<?php endforeach ?>
Can anybody tells me what I am doing wrong?
Thank you very much in advance!
Cheers
What does your content structure look like (folders and files inside the content
folder)?
1 Like
Hm, all one-pager sections should be children of the one-pager
page.
And what about the snippets that are called in the one-pager.php
template, have you created them in the snippet folder? Somehow that example is not very clear, it seems.
1 Like
Yes. They are children of the one-pager.
I have the snippet: pager-headline.php in the folder snippets yes.
And what is in your snippet?
1 Like
A simpe H1 to try if it works:
<?php if($page->headlineone()->isNotEmpty()): ?>
<h1 class="mb0 uppercase bold italic"><?php echo $page->headlineone()->html() ?></h1>
<?php endif; ?>
Ah, that’s what I thought. It should be $part
not $page
. $page refers to the parent page, so nothing will be displayed. You pass the $part
variable to the snippet, you have to use it to make it work.
2 Likes
I am feeling really dumb but I don’t get it working.
Edit: it works! Great thank you! It seems to has to do something with caching in my browser. When I deleted this there was the H1.