next issue . I have two tag fileds in my blueprint which apply separate kids of tags to the posts.
I output the tags (named “services”) from the first field like this:
<?php if(param('tag')): // show service tag results ?>
<?php $tag = urldecode(param('tag'));
$projects = $pages->find('work')
->grandChildren()
->visible()
->filterBy('services', $tag, ',')
->flip()
->paginate(10);
?>
<?php foreach($projects as $project): ?>
which works nice. But can I use the same function to display the post with tags from the other field (named “client”) to? the filterBy gives me no option for this somehow…
I think if you apply two consecutive filters like @ik_arno suggested in the second option , then Kirby will apply the first filter and then the second one on the filtered collection which might not be what you want to achieve, or do you?
What exactly do you want to do? Do you want a user to click on a button to display different filtered page collections? Or do you want to display one or the other on certain conditions, like in @ik_arno first example?
I’d like to filter both separately. If the user clicks tags in one tagcloud it sorts projects only after tags that exist in that cloud. and the same for the other.
none of the above solutions seem to work, but maybe i have an error in my syntax.
<?php if(param('tag')): // show service tag results ?>
<?php $tag = urldecode(param('tag'));
$projects = $pages->find('work')
->grandChildren()
->visible()
->filterBy('services', $tag, ',')
->flip()
->paginate(10);
if(param('tag')){ // show service tag results
$tag = urldecode(param('tag'));
$projects = $pages->find('work')
->grandChildren()
->visible()
->filterBy('clients', $tag, ',')
->flip()
->paginate(10);
}
?>
putting ->filterBy(…) in there twice didn’t work out at all.
but i’d like to keep the URLS clean and untouched as they are. The code i put in my first post works perfectly fine. Is there really no way to dublicate this in a way so it does the exact same thing just with “clients” instead of “services”?
Might work? If there are no results for on services field for Mercedes-Benz it tries again on the clients field. But it might be that the first filter creates an empty $projects because no matches are found.
else
I would make two different fields from type tags in my blueprint:
services: which produces /page/services:design urls
and one:
clients: which produces /page/client:Mercedes-Benz urls
That way you can filter on param(‘services’) and/or param(‘clients’)
so if the href attribute in the link that you click when you want to filter, contains “tag” instead of “services”, the whole thing will return nothing.
@bogus was this ever resolved? I’m having a similar issue. I tried to “duplicate” the existing tag field and insert my new tag field with a different name and could not figure it out. My end goal is to have 6 different filters. @texnixe it doesn’t seem like your solution worked here. Did you two resolve this problem in a pm?