Hello everyone, I’m a student in Web Development, so I’m really debutant. My first teacher of web talked to me about Kirby 3 years ago, and I decided to try it now . I watched the playlist “Kirby Basics” and made the same website as videos without any problem
Now I’m trying to do an other project, and I’m trying to follow the method of “How to create a filter menu”, but for two different “categories”. (in the video he used only one)
So, my question is : Can I use the method “filterBy” for two different filters ?
This what I did : (sorry I’m beginner in development…)
Here is the 2 categories for each project: ‘source_date’ and ‘my_date’
Each categories had a type select and 4 options each.
Here is my documents.php (sorry I didn’t found how to make a better shape to my code in this post)
<?php
//création d'une variable, le paramètre get helper de kirby permet de récupérer whatever query parameter(url) and asign to the variable
$filterBy = get('filter');
$documents = $page
->children()
->listed()
->filterBy('source_date', $filterBy)
->filterBy('my_date', 'novembre 2019')
->paginate(2);
$pagination = $documents->pagination();
?>
<main>
<h1> <?= $page->title() ?></h1>
<ul>
<?php foreach ($documents as $document) : ?>
<li>
<a href="<?= $document->url() ?>">
<figure>
<?= $document->image()->crop(400) ?>
<figcaption><?= $document->title() ?></figcaption>
</figure>
</a>
Date source : <small><?= $document->source_date() ?></small> <br>
Date découverte : <small><?= $document->my_date() ?></small>
</li>
<?php endforeach ?>
</ul>
So with that, when I enter in the url http://localhost:8082/documents?filter=en%202010, it works I there is only document who had ‘my_date’=‘novembre 2019’ and ‘source_date’=’$filterBy’.
So now I want to add $filterBy to ‘my_date’ for when I’ll enter in the url http://localhost:8082/documents?filter=en%202010&?filter=2010 it display only document ‘my_date’=novembre 2019 and ‘source_date’=2010.
$filterBy = get('filter');
$documents = $page
->children()
->listed()
->filterBy('source_date', $filterBy)
->filterBy('my_date', $filterBy)
->paginate(2);
But first : it don’t works, and second I’m not 100% sure it’s possible do that in this way…
Can you show me the right way ?
Ok, so sorry for my approximativ english, I hope you’ll understand me
Thank You !
Clara