Hi I’m new to Kirby,
I’ve watched @bastianallgeier video on youtube and downloaded the starterkit and the demokit to get my head around content, templates and blueprints.
I have a few questions about the demokit.
I looked at the agency homepage ( /agency ) then looked at the files in the demokit. I would have assumed that the following txt file would hold that pages content:
content > 4_agency > agency.txt
But it appears to be:
content > 4_agency > home > agency-home.txt
Am I correct?
Would the template for that page be agency.php?
Looking at that template I understand the
$page object gets all the data for the current page but where are the other vars/object getting defined/set or are they Kirby object like
Are they pulling data from other pages? (Projects and Clients)
Sorry if these are very basic questions.
Yes, this page is rendered using the
agency.php template. But in fact, agency is a parent page, and its content is made up of several subpages,
projects etc. and inside the template, several so called snippets are called that render the content of these subpages.
So its basically a so-called one-pager concept inside a larger site structure: https://getkirby.com/docs/cookbook/templating/one-pager
Thanks for the quick reply @pixelijn and the cookbook link.
I can see the
$projects var is being passed to the
snippet function. That all makes sense.
It’s my understanding that the
$projects var/object is all the sub page data of Projects page.
But where is it being set in order for it to be passed to the
I was expecting to see something like:
$projects = $pages->find('projects')
before line 15.
agency.php controller: https://github.com/getkirby/demokit/blob/master/site/controllers/agency.php
Basically, it works like this:
- Example content file: projects.txt (or projects.en.txt, projects.fr.txt etc. in a multi-language installation)
- Will be rendererd with:
/site/templates/projects.php (if this file does not exist,
default.php will be used instead
- (Optional) Logic for the template:
/site/controllers/projects.php. Returns the variables, that can then be used in the template, helps keep your templates clean
- (Optional) Page model:
- Blueprint for the Panel form:
You might also want to check out this recipe: https://getkirby.com/docs/cookbook/setup/kirby-in-a-nutshell
Thanks so much @pixelijn my mind has been blown!
Haven’t looked into Controllers yet, think that’ll be my next stop.
Thanks for the links.