Query in yaml to pages from everywhere

Hey folks, I’m at a loss as to how to rewrite the query in programelement.yml “query: page.parent.parent.find(‘orte’).children” so that it works regardless of the directory it’s called from. I also can’t use “site” as the starting directory, since the homepage is generated dynamically and is always a year. the other years (2024, …) under content will be only archive.

Im happy for help!

  personsection:
        type: fields
        fields:
          ort:
            label: Ort auswählen
            empty: "Kein Ort ausgewählt"
            type: pages
            query: page.parent.parent.find('orte').children

But wait, the orte page is a direct folder inside content, right? So site.find('orte').children should work. It has nothing to do with your home page.

thx, it may seem like but “orte” is a child of “2025” in this case. So i get the panel error: Your query must return a set of pages" Can i use variables like in php where i just use $home instead of $site? l like

<?php

$home = site()->find(site()->startjahr()->value());

?>

i defined in the website header?

Yes, that should work

But how can i access variables defined in the header like $home in the yaml query? Sorry im new to this

You can’t, but you can use the code that defines $home.