Tried to setup one pager [Kirby 3]

#1

Hello folks,

I tried to follow the sample for the ‘one pager’: https://getkirby.com/docs/reference/panel/samples/one-pager

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

#2

What does your content structure look like (folders and files inside the content folder)?

1 Like
#3

Content

  • 1_home
  • error
  • 2_one-pager
  • site.txt

2_one-pager

  • one-page.txt
  • 1_headline-section

1_headline-section

  • pager-headline.txt
#4

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
#5

Yes. They are children of the one-pager.

I have the snippet: pager-headline.php in the folder snippets yes.

#6

And what is in your snippet?

1 Like
#7

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; ?>
#8

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.

1 Like
#9

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.