Ok, so adding it to site.yml to show in the Dashboard has worked.
Ok, so the preview on the frontend doesn’t work.
Did you already create an events.php
template in /site/templates
?
Ok, so adding it to site.yml to show in the Dashboard has worked.
Ok, so the preview on the frontend doesn’t work.
Did you already create an events.php
template in /site/templates
?
I didn’t add anything to “site.yml” yet. There are two “site.yml” files.
One in “site/blueprints” and one in “content/blueprints”.
I am not sure which one to edit and what to edit.
The preview on the frontend doesn’t work, I believe, because the “events.php” and “event.php” files are empty.
I already created “events.php” and “event.php” in the site/templates folder, yes.
A site.yml
file in content/blueprints
doesn’t make sense, the site.yml
goes into /site/blueprints
. In the /content
folder there should be a site.txt
file.
My mistake: the site.yml files I found are in both the “site/blueprints” and one in “config/blueprints” folders.
I see the “site.txt” file in the “/content folder”. But what do I write there?
Also: do you have an idea what I put in the “event.php” and “events.php” files?
Don’t touch anything inside the kirby
folder.
In the events.php
template, you would loop through the children, similar to what is done in the notes.php
or the photography.php
templates.
While in the event.php
template, you display the single page, i.e. $page->title()->html()
etc., i.e. all the fields you have defined in your event.yml
blueprint.
Ok.
Is it possible to disable the “change template” option in the dashboard?
Can I create another top level “page type” or “page template” in the dashboard?
If so, how do I do this?
This was sort of my original question.
yes, via the changeTemplate
option: Page blueprint | Kirby CMS
Yes, by allowing other templates in the site.yml
pages section. Or by setting up separate section in the site.yml
blueprint.
title: Site
columns:
- width: 1/2
sections:
albums: sections/albums
- width: 1/2
sections:
notes: sections/notes
pages:
type: pages
create: default # this option defines which templates can be used to create new pages, instead of just `default` you can define a liste of templates as below
template: # this option filters the pages to display by template/blueprint
- about
- home
- default
Sorry. I wasn’t clear:
I meant, the “change template” option once “add” is selected is disabled. I want to enable this.
Or do I not need to once I create new sections in site.yml?
Also I have tried the following and it does not render the “events” section properly in the dashboard.
title: Site
columns:
- width: 1/2
sections:
albums: sections/albums
- width: 1/2
sections:
notes: sections/notes
pages: true
type: pages
create: default
template:
- about
- home
- default
- width: 1/2
sections:
events: sections/events
pages: true
type: pages
create: default
template:
- events
- default
The syntax is wrong, there is no pages: true
and the indentation seems to be incorrect as well.
title: Site
columns:
- width: 1/2
sections:
albums: sections/albums
- width: 1/2
sections:
notes: sections/notes
pages:
type: pages
create: default
template:
- about
- home
- default
- width: 1/2
sections:
events: sections/events # have you defined the section in `site/blueprints/sections/events.yml`?
## but why this below if you already add the section in the line above?
pages:
type: pages
create: default
template:
- events
- default
?? I don’t quite get what you mean.
I have this for “site/blueprints/sections/events.yml”
type: pages
headline: Events
parent: site.find(“events”)
sortBy: from asc
template: event
empty: No events yet
sortBy: date desc
I pulled this example from here:
pages:
type: pages
create: default
template:
- events
- default
With the create: default
option you define that new pages are only created with the default blueprint. Set this to
create:
- event
to only create pages with the event
blueprint, or set a list of options. Please see the documentation for section options: https://getkirby.com/docs/reference/panel/sections/pages
Your suggestion is not working for me.
Are you suggesting this:
Please do not post code as screenshots but always as code blocks.
First of all, you use two sections with the same name (pages), which is not possible.
Secondly, what is in sections/events
? Does this file exist? If not, I assume you want to display your events in a section similar to the notes, right?
sections:
events:
type: pages
headline: My events
template: event
The way I have the “site.yml” as defined above in screenshot you told me to paste as code block (which won’t paste for me for some reason) results in this, in the dashboard:
That looks good to me? Now you have an events section with subpages. What happens now if you click on Add
in the events section?
I’d remove the events
page from the pages section underneath, though (in the block with About us, Home, Events)
If you mean here:
Then I am able to create Sub pages i.e. “Let’s go out for ice cream”.
“event.php” looks like this:
<?php snippet('header') ?><?= $page->tags() ?>
<?php endif ?><div class="event-text text">
<?= $page->text()->kt() ?>
</div>
<div class="events">
<?php foreach ($page->children()->listed()->sortBy('date', 'desc') as $event): ?>
<article class="event">
<header class="event-header">
<a href="<?= $event->url() ?>">
<h2><?= $event->title() ?></h2>
<time><?= $event->start()->toDate('d F Y') ?></time>
</a>
</header>
</article>
<?php endforeach ?>
</div>
<?php snippet('footer') ?>
However the date issue hasn’t been resolved on the front end.
I am unable to render the fields (start, end, location, link).
Please advise on how to accomplish this.
Does it have any effect if you just type “Hello” into your template? But this issue we deal with in the other thread, so let’s not mix it up.
Yes, go to: