Show all pages with same field content

I´m on this page:

and i need to display all the Pages with the same Content selected in this field:

How can i achieve this, or is there an easier way to structure this in general?

the code of the page is:

<?php snippet('header') ?>
<div class="wrap wide">

    <div class="textfield">
      <div class="parameter-titel">
        <?= $page->vorname()->html() ?> <?= $page->nachname()->html() ?>
      </div>

          <div class="geb">
            <?= $page->geburt()->html() ?> – <?= $page->tod()->html() ?>
          </div>




      <div class="parameter">
        Jahr
      </div>

      <div class="parameter-info">
        <?= $page->year() ?>
      </div>

      <div class="parameter">
        Werke
      </div>


      <*--- IMAGES OF SAME ARTIST---*>
      <*--- IMAGES OF SAME ARTIST---*>
      <*--- IMAGES OF SAME ARTIST---*>
      <*--- IMAGES OF SAME ARTIST---*>



      <button class="accordion">Info</button>
        <div class="panel">
          <?= $page->text()->kirbytext() ?>
        </div>
      </div>

<?php snippet('footer') ?>

i need to put the neccesary links into the <— IMAGES OF SAME ARTIST—> Part

<?php

// get all werke by a given artist
$werke = page('bibliothek/werke')->children()->filterby('kuenstler', 'name-of-kuenstler');

I don’t know what you actually store in the field, so you would have to adapt this code.

the blueprint of the field is:

  kuenstler:
    label: Kuenstler
    type: select
    options: query
    query:
      page: ../../kuenstler
      fetch: children
      value: '{{uri}}'
      text: '{{title}}'

so in the field all ‘kuenstler’ can be selected, which leads to

mypage/bibliothek/kuenstler/joseph-nicephore-niepce

So it should be something like this:

$werke = page('bibliothek/werke')->children()->filterby('kuenstler', $page->uid());
dump($werke);

seems veeery close, but i get an error:
Call to a member function value() on string

Ah, sorry, $page->uid() already returns a string, so remove the value() thingy, corrected above.

yep, error is gone, got this now:23

there are chrildren objects, but they´re not on the page so far.

Sorry, I’m not yet 100% familiar with php

Hm, the children collection is empty, so it seems the filter doesn’t return any results.

Does it return a result if you hardcode the uid

$werke = page('bibliothek/werke')->children()->filterBy('kuenstler', 'joseph-nicephore-niepce');
dump($werke);

nope,still nothing. but if i rmove the filterby i get all the results:

Ok, I know what went wrong, I used the UID instead of the URI, so this should work:

$werke = page('bibliothek/werke')->children()->filterBy('kuenstler',$page->uri());

Not my best day, today :see_no_evil:

aah, works now! thank you! this brought me a huuuge step forward in my project <3