Current Language in query site.find

Hello!
I have this in my multi-language blueprint:

pagelink:
        label: Page Linked
        type: select
        options: query
        query: site.find('pagetempatename').children.listed
        width: 1/3

But when I change my language, the select still choose the URL from the original language.

What I do wrong?

Thank you!

By default, the ID is stored. You can store the URI instead.

Defining the displayed text and the stored value:

Thank you! Figured out with this:

pagelink:
  label: Page Linked
  type: select
  options: query
  query:
    fetch: site.find('pagetempatename').children.listed
    text: "{{ page.title }}"
    value: "{{ page.uri }}"

and in my template:

<?= $site->url($kirby->language()->code())."/".$data->pagelink()->url(); ?>

Any shorter suggestion for the php code above?
Thank you!

Yes, don’t manually build URLs:

<?= ($page = $data->pagelink()->toPage()) ? $page->url() : '' ?>
1 Like

@mungle I had a type in the above code line, corrected now.