I try to realize this (http://getkirby.com/docs/solutions/one-pager#the-code-home-php-code-template) set up for a subpage – so not for the home page – but since everything turtles one level down I have difficulties to identify each instance where a subpage or a sub-subpage (as in the project folder) is addressed.
Background: I have a site with much information but I want a shorter version in English since not all content is going to be translated. This English content is meant to be displayed as a one-pager.
So instead of the home.php I have an english.php and instead of a code snippet such as
<?php foreach($pages->visible() as $section): ?>
I use
<?php foreach(page('english')->children()->visible() as $section): ?>
So far it does not work. I am not a real PHP professional, so I don’t know the extent of my ignorance here, but I have the impression that I do something wrong with the snippets. Is anybody around here who has done this before and could give me some basic information?
Could you post your structure and the names of the text files? Also, do you use any controllers? Then the corresponding controllers. The error might be there or with the naming of the snippets, or the passing of the correct variables.
Each of the respective folder has a .txt-file: english.txt, about-en.txt, publications-en.txt, projects-en.txt, project-en-1.txt, project-en-2.txt, project-en-3.txt
This would be the english.php (instead of home.php), located in the templates folder:
<?php snippet('header') ?>
<section>
<?php foreach(page('english')->children()->visible() as $section): ?>
<?php snippet($section->uid()) ?>
<!— html for each content section —>
<?php endforeach ?>
</section>
<?php snippet('footer') ?>
@texnix, sorry for not giving a feedback so far. In fact I don’t have any, since I didn’t get this to run, alas! Also I I wonder how to chose between different templates for each section on the panel, since the sections snippets are not shown in the template select field. (Or are they?)
I will try two different setups now though (as a workaround):
to create a onepage template with fields for editable content (like about and contact) and combine it with snippets for the dynamic content. (Something like this: https://github.com/TimOetting/kirby-builder)
to see whether I can achieve sortable sections by creating new article templates instead (without losing my way in a strange loop…).
I don’t understand why this does not work as expected, it does in my test install. Here is what I did:
Created a page structure like yours above, with a page “english” with an english.txt in it and with its subfolders.
Created a template english.php with the code from above:
<?php snippet('header') ?>
<section>
<?php foreach(page('english')->children()->visible() as $section): ?>
<?php snippet($section->uid(), array('data' => $section)) ?>
<!— html for each content section —>
<?php endforeach ?>
</section>
<?php snippet('footer') ?>
Created the following snippets in /site/snippets: about-en.php, projects-en.php, and publications-en.php.
If you want to edit these subpages in the panel, you have to create blueprints with the names of the text files in english/about-en, /english/projects-en, and /english/publications-en, if the text files are called about-en.txt, projects-en.txt, and publications-en.txt, the blueprint names must be about-en.php, projects-en.php, and publications-en.php.
And to answer your question above: No, the snippets are not shown in the select field of the panel, but as I wrote above, you can nevertheless have blueprints for your snippets.