Hello everyone,
I am far from sure that this question hasn’t been answered many times already around here somewhere, but I couldn’t really figure out how to search for that, all my tries only led me to more confusion. Maybe someone can point me into the right direction.
When I am editing content in the panel, I can add another content element before or after the current one, and in the context menu I am offered, I can choose between heading, text, unordered list, etc.
Is there a way to extend that list by my own content types? Like not only “blockquote” but also “blockquote with abackground image (and a field to include the image)” or something along those lines.
I have read about “custom blocks”, but that seems to be about something else. Or am I thinking the wrong way about this?
Oh, thank you for your prompt reply!
Okay, then I was on the right track, but I didn’t realize.
So far, I only found a way to include those blocks in the, say, righthand column of the editor, next to the content editing field, but I couldn’t figure out how to include them into the context menu.
Is there somewhere you can point me to where I find out more about that?
Thank you. This looks very much like what I am after.
What still leaves me a little lost here is that line:
You can add the Blocks field to any fields section in your Panel like this:
I generally understand the way the .yml files work (I think), but I can’t figure out which file I would have to edit there. Is it /blueprints/pages/….yml? Pasting one of the examples there did not work.
yeah. you have to edit the correct .yml file in /blueprint/pages
out of the box kirby will use the default.yml
When you create a new page in the panel you can choose which blueprint you want to use (if you have more then the default.yml)
If you want to edit the default.yml it should look something like this
# Each page blueprint must have a title, the title may be different from the file name
# This default blueprint is used to display a page in the Panel whenever a custom page blueprint is missing.
title: Simple Page
# Each page can have an icon that is shown in page listings when no preview image is available.
icon: 📝
# Page presets are a quick way to set up a standard page layout
# More about page presets:
# - https://getkirby.com/docs/guide/blueprints/presets and
# - https://getkirby.com/docs/reference/panel/presets/page
preset: page
# Custom descriptions of page statuses depending on use case
# More about page statuses: https://getkirby.com/docs/reference/panel/blueprints/page#statuses
status:
draft: true
unlisted:
label: Hidden Page
text: The page is not listed in the main menu
listed:
label: Menu Page
text: The page is listed in the main menu
# Limit subpage display to certain templates in a page preset
pages:
template: default
# A page preset can have a freely defined set of fields
# List of all available field types: https://getkirby.com/docs/reference/panel/fields
fields:
myContent:
type: blocks
fieldsets:
text:
type: group
label: Text
fieldsets:
- heading
- text
- list
- quote
media:
type: group
label: Media
fieldsets:
- image
- gallery
- video
style:
type: group
label: Sonstiges
open: false
fieldsets:
- table
- columns
- code
- stream
- related
pls note that i have 3 custom blocktype under “Sonstiges”
My Kirby-Fu had gotten a bit rusty, and since the documentation is very helpful with what to do, and rather mum at times about where to make the changes (maybe because that is obvious to most people), your kind support was what I needed.
Thanks. I was there yesterday, and hopeful to finally have arrived at the right spot, and then I couldn’t get it to work. Now I think I might have what I need to figure it out.
I have yet another question about this.
I got your example to work, @David, and I tried to include it into one of the blueprints of the Starterkit.
But since I couldn’t figure out where exactly it has to be entered, I saw nothing.
I am working with this blueprint:
# Each page blueprint must have a title, the title may be different from the file name
title: About us
# Each page can have an icon that is shown in page listings when no preview image is available.
icon: ☎️
# Limit the possible page statuses to `draft` and `listed`.
# More about page statuses: https://getkirby.com/docs/reference/panel/blueprints/page#statuses
status:
draft: true
listed: true
# Page options allow you to control how users can interact with the page.
# Here we prevent changing the page slug and page deletion
# More about page options: https://getkirby.com/docs/reference/panel/blueprints/page#options
options:
changeSlug: false
delete: false
# We use tabs here to focus on the layout in one tab
# and have the additional contact fields in a secondary
# tab. Tabs can really help to clean up the interface
# when it otherwise gets too complicated
tabs:
content:
icon: text
label: content
fields:
layout:
label: Layout
type: layout
layouts:
- "1/1"
- "1/2, 1/2"
- "1/3, 1/3, 1/3"
# The contact tab pre-defines a set of address
# fields for the contact box at the bottom of the about
# page. Combining modular content from layouts with
# pre-defined content from such fields is a great way to
# offer flexibility and yet keep certain constraints.
#
# The form layout is created with two columns,
# each column has a set of fields
# More about columns:
# https://getkirby.com/docs/guide/blueprints/layout#defining-columns
contact:
# <content of the second tab, omitted for the sake of clarity>
Inside the content tab, there are different layouts to choose from. I want the custom block to be available after choosing a layout and starting to populate it with blocks.
I suppose I am missing something. I tried to insert your code block (everything between “myContent” and “-related”) with different indentations in different places, but I couldn’t see it like I did when I exchanged the whole blueprint with yours for testing purposes.
I tried taking a step back and learning more about blueprints, since that’s where I am struggling – but so far, that didn’t have the desired effect …
Can you help me with pointing out where in the blueprint I posted you block list needs to be entered?
Hi @David ,
I have one more question about the yml file you posted. I got everything to work, and I felt way more knowledgeable than I actually was, thanks to your help.
Now I am almost ready with my project, but since the customer and I don’t exactly share a language (long story), I’d like to translate everything as thoroughly as possible.
The custom blocks were no problem, but what about the labels in the default.yml, like “Sonstiges”? Is there somewhere I can translate them as well?
(It is probably obvious that I am not exactly the most community-forum-savvy type of person. If this is starting to get too far off the original topic, I will gladly start another thread.)
Well, the multi-lang aspect of it is more between me and my customer. It is a Finnish-language-only site for a Finnish audience. And here I am, being able to count up to three in his language …