Custom Notes (Blog) Post Types in the Panel

:wave: I am sorry to bring my questions to you once again. I feel like this is probably covered, but I am just not putting something together in my brain.

I downloaded the starterkit and it has a Notes feature which is basically a blog. I am trying to create a custom post type called “list”. The cookbook says to structure the content folder like
content

  • blog
    • a-text-post
    • article.text.txt
    • a-nice-video
    • article.video.txt

I have

  • Notes
    • a-notes-list-post
    • note.list.txt

I am trying to figure out how to tell kirby what notes template to use when using the panel to create a new note. I have an note.list.php under my site->template as the custom post type page describes. I would guess I need to do something in the blueprints area, but I don’t see anything about blogs or post types in the blueprints cookbook pages. There is a use the panel blurb but that basically points to a blueprint sample that I do not understand how it translates to custom post types.

If someone could point me in the right direction, I would greatly appreciate it. Sorry if this is like so obvious.

If we take the notes folder as an example:

It has a blueprint called notes.yml. Inside the notes.yml, we define the template/blueprint to use for the subpages:

This references a section blueprint called notes, which you find here: https://github.com/getkirby/starterkit/blob/master/site/blueprints/sections/notes.yml.

As you can see, this section blueprint has only a single subpage template defined: note.

To support multiple blueprints, you would have to change this:

templates:
  - note
  - note.list

And then, in addition to the note.yml blueprint in /site/blueprints/pages you would add a new blueprint for the list variant.

Note that you don’t have to use the section blueprint, but it helps to keep stuff organized.

1 Like

Thank you. As always, you’re amazing. So, there are blueprints in the pages folder for note and notes, and these represent the creation-page for a note, and what the panel-page that lists all the notes. AND there is a note blueprint in the sections folder that represents the home panel-page. Each custom post type should have 3 blueprints each, then, if I am understanding correctly?

I am trying to create a note that I can put in a link to a movie poster image, and at first I was just going to make a url field and figure out how to embed it. I am now wondering if there is a way I can have the poster field search wikipedia for the movie poster image? They are usually fair use and easy for me to use, so it would be great if I could streamline even more. Do you have a suggestion on how I would accomplish this?

Notes is the so called parent page. This parent page can have subpages of one or more types (templates/blueprints). With the template/templates (or create) option in a pages section you tell Kirby which templates can be used for these subpages (and will then be selectable in the template field in the pages creation dialog.

No, that has nothing to do with the home Panel page. Section blueprints are just reusable section definitions, you don’t need to use them, but could define those sections directly inside the parent page.

E.g.

Title: Notes

sections:
  pages:
    type: pages
    headline: Notes
    layout: list
    sortBy: date desc
    empty: No notes yet
    templates:
      - note
      - note.list

Will have the same effect as:

Title: Notes

sections:
  pages:
    extends: sections/notes

with a sections/notes.yml

type: pages
headline: Notes
parent: kirby.page("notes")
templates:
  - note
  - note.list
empty: No notes yet
sortBy: date desc

But often, we want to reuse a section, for example not only on the notes page, where we probably want to have drafts, listed and unlisted subpages in three different sections, and then again in site.yml for the Panel dashboard, where all three statuses in one section. So reusing the section definition, with only a different status setting applied, saves us a lot of repetition.

1 Like

What do you want to do? Download the image and put it in the page folder, or just link to it? What if the search does not return anything?

It would definitely be possible, in a hook or a page model.

I would like to just link to it, or embed it I guess would be more accurate to say. The sane as an img src= if it were HTML. If the search doesn’t retain anything, I could just give it a different link? Or maybe define a default image? Ideal would just be give it a different link. I don’t plan on uploading anything myself.