Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Set Page Frontmatter Variable via Form

Solved by Werner Joss View solution

Started by Werner Joss 6 years ago · 3 replies · 595 views
6 years ago

short question: how can I set a frontmatter Variable for a specific page via Form ?
(Form page is NOT the page I want to modify)

6 years ago

@hoernerfranz, I wonder what the use-case is for this question....

Anyway, I could think of creating a plugin that responds to the form's onFormProcessed event, checks the user action defined for the form, finds the page to be updated and does the update.

See the docs on User Actions for some sample code.

6 years ago

@pamtbaau : my usecase is very simple, and I was well aware I could solve this by creating a plugin - but hoped it could be easier 😄
I have a page which will show different Information based on the value of a boolean Variable in the frontmatter of that page.
of course, that Variable can be set via the Admin Backend, but I wanted to avoid that by just creating a form page which is routable, but not visible in the menu.
The Form simply asks for a Password and should then set the above mentioned Variable via a radio select Field.
The link to the Form Page is then only known to the Operator who does not have to log into the Grav Backend (which would be overkill in this use case)

6 years ago Solution

just for the record: I solved this issue by creating a minimalist plugin which lets the backend user switch a plugin variable via toggle buttons in the Plugin settings page.
the page template then reads that value from the plugin config and displays the desired Text.
so, yes, backend login is now required, but not editing frontmatter (which is not suitable for unexperienced users).

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1165 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 89 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 163 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 138 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 156 7 months ago