Dear Kirby community,
again, I’m a little stuck for quite some while now. I’d like to display some links to pages, filtered via
param(), for example
example.com/semesters, I get a link list of all semesters from a field in
content/1_semesters/semesters.txt. That is the second
foreach loop in the code below and it’s working.
The listed links — when clicked — append a tag to the URL, e.g.
example.com/semesters/semester:2018-ws … where
2018-ws is the keyword I’d like to filter by. Appending the tag and keyword works, but no content is shown. I assume there’s an issue in the
if or the first
My folder structure is the following:
content/1_semesters/semesters.txt content/2_students/first-student-name/student.txt content/2_students/first-student-name/first-project/project.txt content/2_students/first-student-name/second-project/project.txt content/2_students/second-student-name/student.txt content/2_students/second-student-name/first-project/project.txt content/2_students/second-student-name/second-project/project.txt […]
<?php if($filter = param('semester')): ?> <?php foreach ($site->index()->filterBy('template', 'project')->filterBy('semester', $filter) as $project): ?> <a class="project block" href="<?= $project->url() ?>"> <h3><?= $project->project() ?></h3> <p><?= $project->text()->kirbytext() ?></p> </a> <?php endforeach ?> <?php else: ?> <?php foreach ($page->semesters()->toStructure()->sortBy('id', 'desc') as $semester): ?> <a class="semester block" href="<?= $page->url() . "/semester:" . $semester->id() ?>"> <h3><?= $semester->topic() ?></h3> <span>— <?= $semester->semester() ?></span> </a> <?php endforeach ?> <?php endif ?>
Thank you very much in advance for your advice and help.