Blueprint questions

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

I think I already explained this here: How to make a list of case studies with a thumbnail image? - #19 by texnixe

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?

	sidebar:
		width: 1/3

		sections:
			files:
				portfolio_list_image:
					label: Portfolio list image
					type: files
					required: true
					max: 1
			
		sections:
			files:
				images_all: 
					label: All images
					type: files

Many thanks! And sorry for being dim. I am trying! I’ve spent hours on this

Hm, somehow this is now all messed up. With only two files sections, your sidebar should look like this:

sidebar:
  width: 1/3
  sections:
    portfolio_list_image:
      label: Portfolio list image
      type: files
      required: true
      max: 1
    images_all: 
      label: All images
      type: files

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.

sidebar:
  width: 1/3
  sections:
    portfolio_list_image:
      label: Portfolio list image
      template: portfolio
      type: files
      required: true
      max: 1
    images_all: 
      label: All images
      type: files
      template: image

But is this what you wanted to achieve?

To understand the difference between files field and files section: Kirby in a nutshell | Kirby CMS

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

I’m trying loads of things. This looks the best, but it still doesn’t work:

	sidebar:
		width: 1/3

		sections:
			filesfield:
				portfolio_list_image:
					label: Portfolio list image
					type: files
					required: true
					max: 1
			
		sections:
			filessection:
				images_all: 
					label: All images
					type: files

And it’s how it should be.

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?

Thank you as ever!

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).

Do I have three sections in my Blueprint?
• main column
• side column first section
• side column second section

If so, how come only one of those sections needs a key and a property?;

filessection: # Each section needs a key
  type: fields # Each section has properties

No, the first section is a fields section which contains fields.

So could the word filesfield in my code be anything - “cup_cake” for example?

Yes.

But columns, sections, tabs need to be called like this.

But all explained here: Layout | Kirby CMS

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

To me all my Blueprint looks like fields. Do I even need a sections: ?

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.

sidebar:
	width: 1/3

	sections:
		section1:
			type: fields
			fields:
				portfolio_list_image:
					label: Portfolio list image
					type: files
					required: true
	
		section2:
			type: fields
			fields:
				images_all:
					label: All images
					type: files

Does this look okay with you? Thanks again for your time – you always seem to be on here providing help!