Change Info field theme with page variable

Hi there,

i would like to change the theme of a info field with a page variable in the panel. I’ll tried to get the info with {{ page.fieldname }} like I can with other elements but no success so far. Can anybody help?

My Blueprint:

paymentinfo:
    label: Status
    type: info
    theme: "{{ page.paymentstatus }}"
    text: |
          {{ page.paymentmessage }}

Part of my page txt file

Paymentstatus: positive
----
Paymentmessage: Bezahlt

The Message works fine. But the info field in the panel stays as “default” grey.

Thanks for your help and all the usefull stuff i found in this forum!

Not all properties support Kirby’s query language.

You could create a custom info field with support for this feature, though. It’s just replacing the theme prop

  'theme' => function (string $theme = null) {
            return $theme;
        }

with

 'theme' => function (string $theme = null) {
            return $this->model()->toString($theme);
}

As you have probably already noticed, the values do not change on the fly, you have to save and reload the page for the changes to be reflected.

1 Like

Ah ok I see. Thanks for the heads up.

The Idea with the info field extending custom field is a great one - thank you. I will give it a try!

It is totally fine that it is not changing on the fly. The Variable in the page txt file comes from a different place. I just need the changing when you revisit the page in the panel.

Thanks again for the quick response and help @texnixe !

Quick follow up… worked perfectly!