Is there any chance to change the content off a page in a controller - just for the view?

My idea is it to change e.g. the headline of a page just for this specific call.

$page->headline('new headline');

or

$page->headline()->set('new headline');

or

$page->content('headline', 'new headline');

I want to use this for using the text file as default values and update the content if necessary.

Greetings and thanks for you ideas :slight_smile:

You can update field values via $page->update(); but I donā€™t get why youā€™ld want to do that in a controller?

Letā€™s say you have a page with a availability info of a service - usually this service is running but before you render the page you call an API to check it if the API is running or not wit the intention to change the value if notā€¦

Ok, I wouldnā€™t store the availability as a field value, but retrieve it from the endpoint for each call (and perhaps cache it for a certain amount of time). But be aware that this could slow down render time.

Or maybe even handle this in the front-end via AJAX if is not ā€œmission-criticalā€. Then you could still leverage server-side caching.

Youā€™re right it is more a historic ā€˜issueā€™ because authors wanted to change the message. Yeah, but I can return a variable with the updated contentā€¦

Sorry but Iā€™m checking all the changes to v3 and it is a lot behind the curtainā€¦

You could set 2 text fields: successmessage and failmessage that authors can alter.

Depending on the result of the endpoint, you can choose which message should be shown (be it in the backend or frontend).

Yes, might be an other solutionā€¦

Iā€™m checking: https://getkirby.com/docs/guide/templates/page-models

Maybe I can have an even better solutionā€¦

Yes is is - an even more cleanā€¦