Blueprint pages info field with conditionals?

Hi all,

some of my pages have a type: toggle field to switch on/off to get them featured on the startpage.
When this toggle field is activated it gives the value: true

So good so far. In the kirby panel i have so many pages i would like to see in the overview which of them are activated with the featured field of the page.

As a little workaround to get a visual notice about it’s a featured page i use this
info: "<h1> {{page.HomepageFeature.isTrue}} </h1>"

This gives a big plain “1”. But how can i change this “1” to a text? Already tried a few options, but doesn’t work. Already searched for something like if/else statements, but it seems not to work.

All i want is this, just in the query language :wink:
if ($featured == true) { echo "Featured" }

Any idea?
Thx in advance

The query language alone won’t help you here. But you can set up a custom field method that returns some text instead of the boolean 1.

    'fieldMethods' => [
        'convertBoolToText' => function ($field) {
          if( $field->bool() ) {
            $field->value = 'Featured';
          } 
          return $field; 
        }
    ]

In blueprint:

info: "{{ page.toggle.convertBoolToText }}"

Of course, the name of the method is up to you.

Many thanks, your solution gave me the tip with “custom field method”, and i have find out that @bnomei has a plugin that does the same what i want :slight_smile: