Hey,
i managed to build a filter system for all pages in a projects folder. The client can create tags which get listed and are clickable and adds “tag:Selected” (for example) to the url. all projects that have a Video Tag are getting listed. The project that is getting shown is on the right so the filter menu is visible all the time. It looks like this and is basically working fine:
<div class="menu">
<h2>Projects</h2>
<div>
<?php $type = $site->find('works')->children()->listed()->pluck('Type', ',', true); ?>
<?php foreach($type as $tag): ?>
<a href="<?= url('works', ['params' => ['tag' => $tag]]) ?>">
<?= urldecode($tag) ?>
</a>
<?php endforeach ?>
<a href="<?= $site->url() ?>">All</a>
</div>
</div>
<div>
<?php $projects = $site->find('works')->children()->sortBy()->filterBy('Type', param('tag'), ',');?>
<?php
if($tag = param('tag')):
foreach( $projects as $project):
?>
<a href="<?= $project->url() ?>">
<div class="project-list-grid">
<p><?= $project->title() ?></p>
<p><?= $project->Client() ?></p>
<p><?= $project->Year() ?></p>
</div>
</a>
<?php endforeach ?>
</div>
However when a project is clicked the filter jumps back to not filtered and the url goes from
/works/tag:Selected
to
/works/project-1
obviously because thats the link that is set when the project was created
But It should be
/works/tag:Selected/project-1
Is there a way to accomplish this? To keep the filter when clicking a filtered project?
Any help very much appreciated! Thank youuu!
Julius