mafleig
1
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
texnixe
2
<?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.
mafleig
3
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
texnixe
4
So it should be something like this:
$werke = page('bibliothek/werke')->children()->filterby('kuenstler', $page->uid());
dump($werke);
mafleig
5
seems veeery close, but i get an error:
Call to a member function value() on string
texnixe
6
Ah, sorry, $page->uid()
already returns a string, so remove the value()
thingy, corrected above.
mafleig
7
yep, error is gone, got this now:
there are chrildren objects, but they´re not on the page so far.
Sorry, I’m not yet 100% familiar with php
texnixe
8
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);
mafleig
9
nope,still nothing. but if i rmove the filterby i get all the results:
texnixe
10
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
mafleig
11
aah, works now! thank you! this brought me a huuuge step forward in my project <3