The regular value coming out of this select is something like artists/name-bla. To translate it in a readable output I use something like>toPages()->title(). Works.
If I want to build a filter like below but with those page’s titles instead of their shorturl I somehow need to do something similar. But I’m so lost. How would this code look like with >toPages()->title() integrated?
Additional question: If I have the same situation but with just one value because there it would be a standard select field (not a multiselect), I can use the same code, do I?
In the parent page’s controller, you then use the filter, as above, only we need to urldecode the parameter value (I’m using param here instead of the query string):
I think I need to be more clear.
This is my reduced news overview, showing all its children.
The children each have a field “artists” which is a dynamic multiselect of all artists children. This works perfect.
Oh, ok, I see, so the links in the article list are not the filter.
Now for your filters:
// Instead of looping through the plucked filters, get all children pages for the filters:
$artists = page('artists')->children()->filterBy('id', 'in', $filters);
foreach($artists as $artist): ?>
<a href="<?= $page->url() . '?filter=' . urlencode($artist->title()) ?>"><?= $artist->title() ?></a>
<?php endforeach ?>
The for the filtering, use the code I posted above.
Yes! One step closer. Thank you so much for your patience. And sorry for mess.
Now I have the filter-urls i like to have: …/news?filter=Stanley%20Brown But the post loop is not reacting to the filter. See GIF attached.
So went back to my old filter loop from another project to compare them.
How do we marry these two?
Side question: why the urlencoding? With urlencoding it renders a + instead of the whitespaces. Is this okay? I ask because on another project in progresss – Architektur Forum Ostschweiz – the filtering is working without urlencoding.
If you urlencode() the title, you need to urldecode() it again in the controller, if it works without, then all good. I always use urlencoding/deconding