Flexible & dynamic theme approach (Feedback needed!)

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):

  1. The Template, containing all of the html header, the footer as well as a snippet containing the actual page content.
  2. 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

  1. User can choose a template when creating a page.

  2. 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.

  3. 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.).

I’d say that depends on the theme.

It can sometimes be useful to offer only one coherent style and layout to avoid the design issues of the WYSIWYG approach (people who aren’t designers design their layout).

If the one-pager layout should be part of the theme anyway and can be embedded nicely into an existing multi-page site, your solution sounds good. But if only one or the other makes sense, consider releasing two separate themes.

1 Like

Thanks for your feedback, makes sense to us, we will keep that in mind.