Hi there,
New to Kirby, I’m playing around with a one-pager. Populated it with some snippets, which works great. Now, using Portfolio | Kirby CMS I’m trying to create some company portals.
If I go to /companies it seems to be working. But the only page I want to use is the default (eg. www.mysite.com).
The snippet I use looks like this:
<section>
<ul>
<?php foreach ($page->children()->listed() as $company): ?>
<li>
company
</li>
<?php endforeach ?>
</ul>
</section>
, but it only returns a empty ul. My guess is there is something wrong in my /blueprints/sections/companies.yml file, in particular the third line where I set the parent.
type: pages
headline: Companies
parent: site.index.findBy('intendedTemplate', 'home')
layout: cards
template: company
image:
query: page.images.template('cover').first
ratio: 3/2
cover: true
info: '{{ page.year }}'
Any help would be highly appreciated.
Where is that snippet used, in the home.php template? Does the page where it is used have listed children
The snippet is used in /templates/default.php, it’s the Companies one:
<!DOCTYPE html>
<html lang="nl">
<head>
<title><?= $site->title() ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />
</head>
<body>
<?php snippet('header') ?>
<main>
<?php snippet('bar-logo') ?>
<?php snippet('hero') ?>
<?php snippet('intro') ?>
<?php snippet('companies') ?>
</main>
<?php snippet('footer') ?>
</body>
</html>
Listed children… hmz, no it doesn’t. In the panel I can add companies, but not sure yet how to add them as listed child of the default template.
[EDIT]
I’ve managed to add a test company as a listed child on the homepage. But that’s not the same as the default, or is it?
I think I got it working. I published the pages and now if I go to my local website, I do see a populated ul. So the fix was to publish home, companies and testcompany pages in /panel.