Hey everyone,
I tried to extend the starterkit for one more level regarding the page structure. I would like to have a nested structure as follows:
notes
--note
---subnotes
Right now, I have three blueprints:
notes.yml
title: Notes
columns:
- width: 1/1
sections:
drafts:
extends: sections/note
headline: Drafts
status: draft
unlisted:
extends: sections/note
headline: In Review
status: unlisted
listed:
extends: sections/note
headline: Published
status: published
note.yml
title: Note
columns:
- width: 1/1
sections:
drafts:
extends: sections/notes
headline: Drafts
status: draft
unlisted:
extends: sections/notes
headline: In Review
status: unlisted
listed:
extends: sections/notes
headline: Published
status: published
and subnote.yml
title: Subnote
status:
draft:
label: Draft
text: The dossier is still in draft mode. It can only be seen by editors with panel access.
unlisted:
label: In Review
text: The dossier is online and can be visited with the direct URL. The team must still give the final go to publish it.
listed:
label: Published
text: The dossier is online and listed in the blog
columns:
- width: 1/1
fields:
introduction:
type: textarea
Although I applied the logic of ‘notes’ to ‘note’ it throws an error: The section “drafts” could not be loaded: The parent for the query “kirby.page(“note”)” cannot be found in the section “drafts” when I try to access a ‘note’ page.
It looked fine when I removed parent: kirby.page("note") from the subnotes.ylm but got an error in return when I tried to loop over the children of the ‘notes’ pages.
I don’t know what to change anymore to try to resolve this error so I appreciate any help!
Please don’t use the quote button for code snippets but three backticks before and after your code snippets, otherwise it is completely unreadable. I will fix it for now, but please keep this in mind for the future.
Thank’s for the reply. My page note should have a page where all subnotes are displayed with ->children()
So I would like the page note to exists. Can you give me a hint where to change things to be able to create that page?
The first level parent is notes, then underneath that page you only want one note page (not multiple children), and then this single note page can have multiple subnotes ? I was under the impression that you wanted multiple note type children under notes which would in turn have subnotes.
I have four notes pages, each of them has three note pages each of which has three subnotes. I would like to have a page for each note on which i loop over its children subnotes. This however throughs an error when opening one of the note pages: Call to a member function children() on null
That’s what I already said above, you don’t have a page that is called note (or in any case, there can only be one page with the slug note inside one parent folder.
Additionally, the page helper needs the full path to the page, and since any note page is a child of notes, the path would be page('notes/note') or whatever the real slug is.
But since you have multiple of these pages, it wouldn’t make sense to hardcode the path.
But is it possible at all to create a nested tree structure like this in kirby? Multiple child pages each having multiple child pages? Sorry if I misunderstand you!
Yes, that is perfectly possible. But I don’t really understand in which template you are trying to use that code. It doesn’t usually make sense to try and fetch dynamic pages by there IDs. I think we somehow are talking cross purposes and need to clarify what exactly you want to do where.
<?php foreach ($articlegroups = $site->page('notes')->children() as $articlegroup): ?>
< ?php foreach ($articles = $articlegroup->children() as $article): ?
to show the content of all subnotes pages grouped into their note and notesgroups – wich works perfectly fine. The issue occured when I tried to also be able to look at the note groups individually, e.g. to open Page B-2(note.txt) from the CMS and to display it’s children there via the line <?php foreach ($articles = $page->children() as $article): ?> in note.php.
I hope this explains a little better what I am trying to achieve.