Get title of page from slug stored in select field

Hey Friends,

i´ve a problem with showing the title of a select-field.

My Blueprint:

        label: Sektion
        type: select
        options: query
          page: programm/struktur/sektionen
          text: '{{title}}'

My Template:

… <?= $page->sektion() ?> …

Output on frontend:


But it should be:

Sektion what ever name

If anyone could give help or a hint, it would be amazing.
Thank you in advance!

I am a bit confused. I guess you accidentally chose the wrong question label und mean Kirby 3 not Kirby 2?

So what you are querying is your select field is structure field?

Please use three backticks before and after a code block to format your code.

thanks! No, its KIRBY2.

What I want querying is the title of a select-field yes.

For Example: There are 3 pages in “programm/struktur/sektionen”
—> Sektion A
—> Sektion B
—> Sektion C

In the panel I select “Sektion A” in my select-field.
On Frontend the output is “sektion-a”. But It should be “Sektion A”.

Sorry for my bad english :wink:


The you have to convert the select field value into a page first.

if ( $p = page($page->sektion()->value()) ) {
  echo $p->title();

if your select field only stores the slug, then you need to pass the complete path to the page helper

if ( $p = page('programm/strukturen/sektionen/' . $page->sektion()->value()) ) {
  echo $p->title();

Thank you for you answer. But there is no output… ;(

    <?php if ( $sektion_title = page($page->sektio()->value()) ) {echo $sektion_title->title();} ?>

I don’t know…

Typo in field name…

also not working my friend

As I already wrote above, the page helper needs the full path to the page, if only section-a is stored in your field, then the page will not be found unless you add the rest of the path.

still no output. I testet the path. Its correct.

<?php $sektionen = page('programm/struktur/sektionen')->children(); ?>
 <?php foreach($sektionen as $sektion): ?>
 <?= $sektion->title()->html() ?> <br />
<?php endforeach ?>
<?php if ( $p = page('programm/struktur/sektionen' . $page->sektion()->value()) ) 
  {echo $p->title();} ?>

There’s a slash missing

Works like a charme! You are an angel ;D

<?php $sektion = page('programm/struktur/sektionen/' . $page->sektio()->value()) ?>
<?= $sektion->title()->html() ?>

Have a good day!