But I can not get it to work, is there a real-world example of a blueprint-file that someone can share and teach me ?
I have found other solutions, such as adding these values hidden, or adding fields under admin overrides below the advanced tab when using Grav Admin Plugin but as the documentation suggests I would prefer this solution.
Is it possible to specify defaults that are then editable from admin ? For example, an editor of the webpage creates a page and get’s the default values set but is then able to add (or maybe remove) categorys, tags manually.
This above file (blog.yaml) is cut in this post after my edit because I didn’t manage to paste it all as preformatted text.
Made sure that taxonomies are set in site.yaml (…/system/config).
Created both pages with blog or item setting.
Saved the pages, returned and doublechecked both forms and frontmatter in admin (via expertmode) and finally via VSCode the Markdown files but there was no category set.
I have also experimented with adding this piece of code to forms and/or advanced tab/overrides
@grelle Blueprints are not the easiest part of Grav. And especially the pickiness of Yaml on indentations, make it hard to create correct blueprints.
It is hard to judge from the snippet you copied, but it seems the definition of the blueprint needs a bit more attention… May I suggest to have a look at the documentation about Forms?
To create a correct form, follow the following steps:
First have a look at the default definition of ‘default.yaml’ in folder ‘/system/blueprints/pages/’. That will give an idea of the layout of the default template in Admin. Quark has extended that blueprint in ‘blog.yaml’.
The blueprint has the following structure:
title: PLUGIN_ADMIN.DEFAULT
rules:
slug:
pattern: '[a-zA-Zа-яA-Я0-9_\-]+'
min: 1
max: 200
form:
validation: loose
fields:
tabs:
type: tabs
active: 1
fields: <-- Below you will find the definitions for tab fields
content: <-- Tab definition for tab 'Content' at top of page in Admin
type: tab
title: PLUGIN_ADMIN.CONTENT
fields: <-- Below are the definitions for fields
...
options: <-- Tab definition for tab 'Options' at top of page in Admin
type: tab
title: PLUGIN_ADMIN.OPTIONS
fields:
...
If you want the Taxonomy field in the ‘Options’ tab (as it is by default), then add the following definition right below ‘fields’ below ‘active 1’ in ‘/user/themes/quark/blueprints/blog.yaml’. That is probably line 17 in Quark v1.2.5:
options:
type: tab
title: PLUGIN_ADMIN.OPTIONS
fields:
taxonomies: <-- Copied from the example in the docs
fields:
header.taxonomy:
default:
category: ['blog','page']
tag: ['test']
options:
category: ['grav']
validate:
type: commalist
Make sure you apply the right indentation…
Almost forgot… Don’t make these changes inside the Quark theme, but create an inherited theme for these changes. If you don’t you will loose the changes when Quark gets updated.
Thankyou for your kind help. I feel stupid because I can not get it to work as I understand that should work when reading the docs. My understanding is that it should keep the original “taxonomy” field and just add the default values when creating the page.
This is the whole of my …/system/blueprints/pages/default.yaml after trying my best to edit at your proposal.
I did try with the original “taxonomies” code present and removed, it does produce the same result. I did remove it because VSCode with YAML plugin from RedHat warned me about “duplicate key”.
The result is, original taxonomy fields are gone in admin, and there is a single row (see screenshot) with input field at the top of “options” tab without label and no predefined data, neither any options…
There is also no default set data in frontmatter for the pages I create.
@grelle, I may have lead you astray by referring to ‘/system/blueprints/pages/default.yaml’ as a point of reference…
The blueprint ‘/user/themes/quark/blueprints/blog.yaml’ is derived from ‘default.yaml’ and therefor you need to know how ‘default.yaml’ looks like and what you are ‘extending’…
The changes should however be made in the derived blueprint ‘/user/themes/quark/blueprints/blog.yaml’ as you correctly started out with in your step 2.
By ‘extending’ a parent blueprint, the child inherits the definitions of the parent and extends on those definitions. Since you made the changes to the parent, you have deleted some essential definitions, like section information (the title ‘Taxonomies’) and definitions of the field ‘header.taxonomy’ itself…
Bonus:
After you have mastered applying changes in Quark, you might want to take up the challenge of making the changes in your inherited theme… You might be suprised how trimmed that blueprint will look like.
I discovered that, made changes accordingly. Cleared Grav cache (which is set to off though). Cleared webbrowser-cache. Refreshed admin and created a new blog page…
I’m a bit puzzled about blog.yaml though. It has a section with a tab setting with title: “Blog config”. That is not showing up in my admin of any of my pages.
blog:
type: tab
title: Blog Config
I guess I should see that to confirm I’m in the right place searching for my taxonomy fields…
EDIT: Now I see that this is stuff that is being set in frontmatter but not editable in admin.
EDIT: This section was not visible in admin most probably of some error in my blueprint, I now see it after I managed to correctly set my blueprint.
tabs:
type: tabs
active: 1
fields: <-- Containing the list of tabs (sub-fields)
content: <-- Start of definition of tab 'Content'
type: tab
title: PLUGIN_ADMIN.CONTENT
fields: <-- Containing the list of fields on tab 'Options'
# .... other subfields