3 times a blog. How to make 3 pages with 3 sections dynamic?

I am stuck. I have a static html site, that I want to tranfer into Kirby. I have 3 pages with a topic:

Banana

Guave

Orange

——

Each page has 3 sections, so (apart from header/ footer etc.) the pages look like this:

Banana Infos

Banana Pictures

Banana News

Guave Infos

Guave Pictures

Guave News

Oranges Infos

Oranges Pictures

Oranges News

My site yml just has preset:pages.

I have 3 content folders:

3_Banana

4_Guave

5_Orange

Inside the 3 content folders:

banana.txt

Folder: „article-banana“

Inside: article-banana.txt

guave.txt

Folder: „article-guave“

Inside: article-guave.txt

oranges.txt

Folder: „article-orange“

Inside: article-orange.txt

All article-fruit.txt files have the fields:

Title:


Text:


Files:


Date:


Author:


Tags:

——

I made the corresponding blueprints in blueprints/ pages/

banana.yml

banana-article.yml

guave.yml

guave-article.yml

orange.yml

orange-article.yml

Since I copied the blueprints from the cookbook, I have

„ extends: sections/articles“

in the yml-files of the fruits. I guess this is the first source of mistake.

And I made the templates

banana.php
banana-article.php

guave.php
guave-article.php

orange.php
orange-article.php

—————————

Problems:

When I make a new post from the first level of the backend I can choose several article types, like banana-article etc. If I choose „banana-article“ I get the correct article type, but it chooses the template for the homepage. Also, it doesn’t appear on the banana page. Some with the other fruits.

So, I need to change - what?

Also I can choose article types of just „banana“. If I do so I can choose another article type called „article“ with the standart layout for subpages and files. Not the layout with the meta stuff, that I defindes in my „banana-article.txt“

Also I have to choose which position in the menu, which I don’t want.

Were? Did. I.Go.Wrong?

It feels like I chose the wrong way to achieve my goal.

PS: Later I want to change the post type of the pictures articles and I also need to figure out how to make the navigation work.

I can’t concentrate a lot today, but first question:

Why do you use different content text files for the same sort of stuff?

If they all have the same fields, they should probably share a blueprint/template?

So I would use a fruit.yml blueprint and a fruit-article.yml blueprint.

But how does Kirby then know which template to use? I guess that is still a mystery for me. Edit: Oh by the content folders, right?

Do you want to use different templates for the main pages? Then you can do one of two things:

  1. If they have the same type of content, use one blueprint & template, but different snippets for the different layouts

  2. Use different templates/blueprints like you had planned above.

Since the subpages only deliver content for the parent (the three sections, they can in any case share the same blueprint (they then don’t need a template at all)

The name of the text file (and hence the blueprint) determines the template that is used to render the content.

The templates for each fruit-topic are the same.

fruit-infos: ~3 excerpts/ intros with links to the corresponding articles. Plus a back link.

fruit-photos: a slider with photos. Each photo could be a figure with figcaption, wrapped in a link, that leads to a page with a grid of fotos with some more informations to it. Like a grid of divs with a photo in each and some text fields in each.

fruit-news: ~3 excerpts/ intros with links to the corresponding articles. Plus a back link.

I chose different content folders and different blueprints and different templates just because it means less complexity for my brain. But I know its more work.

What is the number with the underscore for in the content pages folders? I can’t find an explanation. Is it for an automatic menu?

I think, you should use one template for all of them and you should unite/make one for fruit-infos and fruit-news because it’s at the end the same structure like you wrote here.

I think your issue is a bit bigger because at the end, you have different open questions. In my point of view, we should reduce the complexity step by step and then it will be easier for your brain to understand the whole thing. It’s hard to try to solve a problem/complex situation without splitting it into different sub-issues, like you did.

For example to limit the templates you can choose from, you could create a blueprint with type pages like in this example for articles.yml:

type: pages
headline: Articles
info: "{{ page.creation_date.toDate('d.m.Y') }}"
template: article
empty: No articles yet
sortBy: creation_date desc

(see the template option)

The numbers/missing numbers in the directory/folder names are used to determine the status of a page: in draft, in review or published.

You can read more about it here:

https://getkirby.com/docs/guide/content/publishing-workflow#page-states

There’s also different numbering schemes for listed pages, you can find information about the numbering schemes here: https://getkirby.com/docs/guide/content/publishing-workflow#listed-pages

As regards the listed, unlisted and draft states: As far as I know, you have worked with Kirby 2 before, right? Listed is the old “visible” status, unlisted the former invisible and the draft state is new.

I think it’s probably a good idea to go through the first few chapters of the guide to get a general overview.

Yes, I Kirby 2. I did read thru the guide. I have several open tabs with it.

Let me beat my head against your answers and the guide for just a while. I come back later.

2 Likes

:+1:

I’m sure you will find the proper solution to your need! I had the same starting issues and I’m becoming more and more fluent with Kirby 3. It’s not too easy but saves a lot of headache and issues later on. As always, we are here to help each other :wink: .

12 posts were split to a new topic: How to specify the templates that are allowed for the first level of pages

The first problem I had was that I had a sections folder with a articles.yml and a„ extends: sections/articles“ in … äh … some other yml file. This was the main confusion. It is in an example for the blog, but not in the cookbook recipe. But I can’t find it anymore.

Stripped it out an chose “create” for a list of possible templates and it all behaved like I expected.

Now I can see the bigger problem, that I have with all the content I have to pull into all those sections on the pages. Now I understand how snippets will help me.

I will:

  • make 3 templates for each fruit page. Throw aways the article.php template but use snippets.

  • put snippets into each info or news section of each fruit page, so I can pull news or infos into each of them on every fruit page. These snippets are all the same article templates with a different title.

Not sure about the yml files to use the snippets instead of articles?

In what way are these fruit pages different? I’m not sure you really make your life easier if you use different templates for the same thing. It means more files and any changes would mean you have to make these changes in multiple places.

There are no yml files for snippets. Yml files (blueprints) are “page based”, that is, each content folder has a text file with a specific name, the name depends on the blueprint selected when the page is created. If you create a new page via the Panel, and in the create dialog you choose template: note then this will create a content file called note.txt (or note.languagecode.txt in a multilang install).

The headline ist different… :wink:

I decided for 3 templates just because I don’t fully understand how to pull it off with just one. But maybe I get it when I do it.

And - I don’t know how the site will evolve over time. Maybe content and therefor Layout will change, I don’t know yet.

Which headline? In the blueprint? Or in your content?

In the content. There is a Headline in each section, that is hardcoded. Ok, I know, I could make it dynamic… :wink:

Edit: Don’t want to show what was here anymore. Wasn’t so relevant anyways.

You should, that’s the whole purpose of using a CMS.

Having said that, it is of course totally up to you what you do with Kirby. But we are here to try and teach you how to get the most out of it. It doesn’t really make sense to have to go into a template to change a headline instead of changing it through the Panel.

1 Like