Creating a page from subpages with structure field

Hi there,

after looking for a cmf, I decided to rebuild an older page with Kirby. This is my first project with Kirby, so I’m totally new to this stuff :slight_smile:

My question is about a page with a long list of publications.

I created a page »publications«. This page will contain a lot of subpages. Every subpage has a field for the year and three additional fields – title, description and download field. They are wrapped in a structure field.

The html structure from a subpage will look like this:

year

title

description

download pdf

This is my blueprint (publikation.yml):

title: Publikation

pages:
hide: true

options:
delete: true
status: true

fields:
title:
label: Title
type: title

publikationlist:
label: Publikation Liste
type: structure
sort: zip, asc, street, asc
flip: true
fields:
description:
label: Beschreibung
type: textarea

In the backend everything works fine. My problem is, how exactly to put the php code in template together with a foreach loop.

thanks

You need two foreach loops here, the first for the children, and the second one for the structure field:


foreach($page->children() as $subpage):
  $publications = $subpage->publicationlist()->structure();
  foreach($publications as $publication):
    echo $publication->description()->kt();
  endforeach;
endforeach;

Hi,

thank you for you quick answer. I’ll have to rename a few things (templates, snippets and blueprints) and will test your code.