Hey there,
I am trying to transfer a website into the Kirby CMS and ran into some problems with the overall structure of the site.
The website is about an university course and the site I am talking about is this one: http://digitaldesign.io/
My problem is kind of related to those:
Because I am really new to Kirby I am trying to figure out if I am doing it right or if there is a fundamental wrong approach in setting this site up. I try to explain my process of thought:
- After the slider i got 3 of the same content types. I call them content-blocks. I want to reuse those content-blocks in all of the different sections.
- The site is divided by sections like “Study, University, …, Apply” etc. where you can scroll to. Content-blocks can be created in every one of those sections. For each one of those sections I created a snippet (followed along the kirby solutions here: https://getkirby.com/docs/solutions/one-pager)
- Each of those snippets yields a page which should be able to create subpages where you can chose from a template: e.g: "content-block, content-table, arrowed-list, … " etc. like you can see in this picture.
- My folder structure looks like the following:
Now I want to fetch all my sites with its different subpages in the home.php file and display them. I do this like the following:
home.php
<?php
snippet('header');
snippet('slider');
foreach($pages->visible() as $section) {
snippet($section->uid(), array('data' => $section));
}
snippet('footer');
?>
Then I iterate over the visible pages in study.php
<?php
foreach(page('study')->children()->visible() as $content):
snippet('contentBlock', array('data' => $data, 'content' => $content));
endforeach
?>
However if I add
snippet('contentBlock', array('data' => $data, 'content' => $content));
to the foreach loop I will of course get a false result, because there is not a content-table for every visible page on my site and I will get something like this:
As you can see I have some troubles in understanding of what would be the proper approach in the overall setup of the site. I want the editors to be able to add different types of content in the different sections of the page. However I don’t know how to fetch all sub pages like: for all pages on the site get each of their individual sub pages and render them to view.
At the moment the panel is choosing the “contentBlock” template from the snippets folder? How can I change that, so that I can create it in the template folder and the different pages are referring to it?
I hope you can provide me with some help.
Kind regards,
Andreas