I have a two column blueprint. I don’t think I have any need for ‘sections’.
The main column works fine with no sections. But the second column will not work without one. Why is this?
The side column has something called ‘filesfield’: a new fields section. So a section within a section?
The side column also has ‘type: fields’ which the main column doesn’t have. Why does the side column have more code to get it to work than the main column, which simply has the code ‘fields:’?
I also don’t understand why my images_all code isn’t indented the same as the portfolio_list_image above it in the code?
I’ve annotated my code below.
Thanks for any help
title: Default Page
columns:
main:
width: 2/3
fields:
title_meta_tag:
label: Title meta tag
type: text
description_meta_tag:
label: Description meta tag
type: text
menu_name:
label: Name for menu
type: text
heading:
label: Heading
type: text
subheading:
label: Sub heading
type: text
image_content:
label: Case study images
type: files
text_content:
label: Text
type: textarea
size: large
sidebar:
width: 1/3
sections: # why do I need a section?
filesfield: # a new fields section. What is this?
type: fields # why do I need this?
fields:
portfolio_list_image:
label: Portfolio list image
type: files
required: true
images_all: # if I indent same as portfolio_list_image it doesn't work
label: All images
type: files
You cannot mix fields with sections in the same column, to do that, the fields also have to live in a section (a fields section, see section types: Sections | Kirby CMS)
Your first main column only has fields, so no need for sections there.
Okay, in my side bar I now have two sections. The top section for me to select one image to use (like a thumbnail) in my portfolio links. And the bottom section to show all the images in the case study content folder.
But only the ‘all images’ list is displayed in the Panel, with the label/name “Files”.
In the side bar I don’t think I’m mixing Fields and Sections? So I’m not sure why the side bar needs sections? And why isn’t it working?
But I wonder why you have changed this now, because you don’t have a select field anymore, but only two sections which will show the same stuff. To create two sections which show diferent stuff, you would have to assign different file templates, e.g.
So all of the code in the side bar goes into one section? What’s the point of the section – I thought sections were to keep things apart that are not compatible?
The top “section” or 'portfolio_list_image should be a way for me, in the Panel, to select one key image (we have called it a ‘cover’ image) to be used on my list of case studies (that is used on most pages of my website). I suppose this might be called a thumbnail?
The following code works, but I would like to understand it:
sidebar:
width: 1/3
sections: # why do I need a section?
filesfield: # a new fields section. What is this? A section inside a section?
type: fields # why do I need this?
fields: # not sure what this does? The stuff below are Files not Fields?
portfolio_list_image:
label: Portfolio list image
type: files
required: true
images_all: # if I indent same as portfolio_list_image it doesn't work. I guess this is a Files section because I want it to show all the images in the pages content folder?
label: All images
type: files
sidebar:
width: 1/3
# If you use the `sections` keyword, it means that what follows on the next indent level
# can only be sections (of type files, pages, info, fields).
sections:
# Each section needs a key
# filesfield and images_all are the names of the two sections (they are on the same indentation level
filesfield:
# Each section has properties
# The most important property of a section is the type
type: fields
# A fields section also needs to define its fields, this fields section only has one field, portfolio_list_image
fields:
portfolio_list_image:
label: Portfolio list image
type: files
required: true
# this is the second section, same indentation level as `filesfield`
images_all:
label: All images
type: files
If you indent images_all so that it appears on the same indentation level as portfolio_list_image, it becomes a field of the filesfield section.
I said it before, yaml is a hierarchical file format, where the hierarchy of elements is important.
Each element can have certain subelements, e.g tabs can have columns but not the other way round. It’s like in HTML, where an element is only allowed to have certain other elements inside but not others. Or an element like img has a list of allowed attributes (alt, src, etc.).
How come my second section, if all sections need them, does not have the following. Nor does my first column (which doesn’t have a section, but I presume by default it does)
filessection: # Each section needs a key (A filesection allows me to 'select' files?)
type: fields # Each section has properties
fields: # A fields section also needs to define its fields
For the sake of clarity – for me – I’ve actually written in a second ‘section’. And this doesn’t work:
sidebar:
width: 1/3
sections:
filesfield:
type: fields
fields:
portfolio_list_image:
label: Portfolio list image
type: files
required: true
sections:
filessection: # does a filessection show everything by default?
type: fields
fields:
images_all:
label: All images
type: files
Because you can only use the sections keyword once inside a tab/column/blueprint. I’m repeating myself, but sections indicates that what follows in the hierarchy are sections (of different types).
Okay… but how come my second section doesn’t need all the stuff the first section needs? Or my first column?
filessection: # Each section needs a key (A filesection allows me to 'select' files?)
type: fields # Each section has properties
fields: # A fields section also needs to define its fields
Just so I can understand: my second column needs a section because the code is doing two different things that need to be kept apart? The first section is a filesfield and the second a filessection?
No, the first section is a fields section which contains fields. Inside this fields section you have one field portfolio_list_image (but there could be more fields).
Oh. I’ve spent hours trying to get my head around the difference between filesfields and filessections. Thinking that the word filesfield meant something in my code. Kirby in a nutshell | Kirby CMS
No, just something I made up quickly because you already had a section called fields in th main column, and these keys need to be unique. Maybe should have called it fields2.
So each section needs a name and that name can be anything (letters and underscores). A section does not need to state wether it is a filessection or a filesfield.
Ok, this seems to work and I can understand it. Both sections in my side bar have a name and both state what type they are. So both sections have the same amount of information. I could not understand why previously my second section didn’t have a name or type, but my first section did.