Backend templates <--> file name <--> templetes

Hello,

I carry on my journey through Kirby. I don’t understand the relation between the tamplates in the backend, the from the backend created filenames and the tampletes.

What’s the missing link? I don’t find an answer in the handbook.

FUSS

The title that appears in select is taken from the blueprint title

For example, this. is the default.yml blueprint from a StarterKit:

title: Page

fields:
  title:
    label: Title
    type:  text

  text:
    label: Text
    type:  textarea

As you can see, the title is “Page”, so it appears as Page in the Vorlage-Select.

What you really select here, is a blueprint, not a template, because the blueprint contains the fields for the edit form, not the template.

Might be a bit confusing, but the templates in the /template folder are only used to render stuff in the frontend. Whereas the blueprints are the “page templates” for the Panel.

1 Like

Very interesting. That means, that the filenames in the content folder defines the possible fields. In the next step, it is possible, to define a template for every blueprint. If not, Kirby uses the default -Tamplate.

I can name the files in the content folder like
a) the file name in the blueprints folder
b) like the text after "title: " in one of the files in the blueprints folder.
But it’s not enough, if there ist a tamplate file with the same name.

Right?

You are so kindly to me.

It’s slightly different:

  • If you create a new page in the Panel and choose the blueprint with the title “Page” (which has the filename default.yml), you will end up with a text file “default.txt”. So the filename of the blueprint determines the filename of the text file, not the title of the blueprint. So the title in the blueprint file is arbitrary and shouldn’t be used for your content text files.

  • The blueprint defines the fields that are available when a user edits a page in the Panel. If your about.yml blueprint contains only two fields, let’s say title and text, and you go ahead and create an about.txt content file manually via the file system with more fields, for example, an additional ID field, a user who opens this page again in the Panel will only be able to edit the title and the text, but not your ID field.

  • If you manually create a text file “test.txt” and there is. no blueprint called test.yml, this Page will be opened in the Panel using the default.yml blueprint.

  • For frontend rendering, the filename of the text file determines the template that. is used to render the page. If a page has an about.txt text file, Kirby. will check if there is an about.php template. If yes, it will use. that template to parse the content. If not, Kirby will fall back to the default.php template.

The blueprint title can also be localized like a field, for example, about.yml

title:
  en: About
  de: Über uns

A user with German as user language (user language selected in the user form) would see “Über uns” in the select field, a user with English as his user language would see “About”. The text file will be called about.txt in both cases.

1 Like

If I understand it right, I can change the title in the blueprint file every time

Can a user see the content of fileds, that the template doesn’t uses - e. g. in the code of the displayed website? If not, I can define a field lieke “to do” in the file.

Yes, exactly.

That depends on whether or not the template fetches the content of this field. Templates don’t do this automatically. You can add 100 fields via an editor or via the Panel and only fetch two of them in your template. Templates and blueprints are in no way related.

Don’t quite what you mean here.

My question was about the fields, that the template don’t know. Is the content visible indirectly to the visitors?

(Auf Deutsch: Ist der Inhalt der vom Template nicht benötigten Felder den Besuchern der Webseite in irgendeiner Form zugänglich, z. B. über den Quelltext der ausgelieferten HTML-Seite? Wenn nein, kann man in der *.txt-Datei einfach ein Feld “Notiz” einfügen und sich notieren, was man noch ergänzen möchte z. B.)

As I already said above, a template doesn’t render anything automatically.

You can add as many fields in your text file as you want, as long as there is no <?= $page->mySecretField() ?> call in your template, nobody will ever get to see this content.

You can even add/define this field in a blueprint so that you can edit your Notiz field via the Panel. These things are completely independent. If you use the Panel to edit your files, I would add these fields in the blueprint, so that you don’t have to go back to the text file to look at your notes. If you edit your files via a text editor and don’t use the Panel for editing at all, you don’t need blueprints (unless you want to keep them as a reference to look up what fields are used where).

1 Like

Thank you very much.