We had some thoughts on how to be as flexible as possible when it comes to the creation of a theme for kirby and came up with the following. I would love to hear if you think there is a more clever way to achieve what we are trying to achieve. Feedback of any kind is very welcome!
The Mission
We want to use pages with templates in a way that each page can have it’s individual styling by choosing a template, but in a way that this page can also be used as part of a one-page-layout which means as one of more section of a certain page.
What does that mean? Every page should have a template (even the „home“ page) which defines it’s style and layout. There will be multiple section templates like „Portfolio“, „2-Column-Text“ and more plus there will also be a “onePager” Template.
If the user chooses the “onePager” Template, all of the sub-pages (or the main pages if the home page is a one-pager) should be displayed inside the one page.
The Solution
a) We will create the following files for every “style” (of sections/pages):
- The Template, containing all of the html header, the footer as well as a snippet containing the actual page content.
- The Snippet, which displays the actual page content.´
b) We will create one template file onePager.php, which loads all children of the actual page via a snippet, that should have the name of the template.
Result
-
User can choose a template when creating a page.
-
If the parent page has a “onePager” Template all contents will be displayed without header html data (using their snippet, no additional template) and a click on the menu slides down to the element.
-
If the parent page has a normal template all elements are included in a menu that directly links (redirects) to the page, that also contains all html header data. (Using their template, with snippet within.).