I have a some general fields that I want to use in the entire Kirby project.
So far I have created such general fields via a general.yml in pages, e.g. like this:
title: General
image:
query: false
icon: ⚙️
back: white
preset: pages
I then have to create a page of this type and remember the page name. From then on, wherever I needed these settings, I accessed them in this way:
<?php $general = page('general'); ?>
There are two disadvantages to this approach.
1. I have to lock the page after creating it so that users cannot change or delete it:
options:
changeSlug: false
changeStatus: false
delete: false
2. The fields are accessed via the saved page name ‘general’ and not by a definition in the code. This is at the expense of reusability in multiple projects, as the name can be prone to errors.
What is a sensible best practice to create general options and settings and reuse the method in different projects?