Hello,
I am building a website at the moment where the navigation works via tags that are organized in a select dropdown, every item (in my code $work) has multiple tags assigned. Now when I open an item i still want the select dropdown to show the previously selected tag. Right now this is not the case because I linked with the url of the item but is there a way to just add to the current url with the selected tag and then add /item? I couldn’t find anything (or I didn’t word my search entry right).
so right now this → http://localhost:8080/tag:books
links to this → http://localhost:8080/damask#page://A9tIyhW7eofn5OEk
but it should link to this → http://localhost:8080/tag:books/damask#page://A9tIyhW7eofn5OEk
my code currently looks like this (both parts are in different snippets)
first the code for the select menu
<?php
$filterBy = get('filter');
$works = $site
->children()
->not('error')->not('home');
if($tag = param('tag')) {
$works = $works->filterBy('tags', $tag, ',');
}
$filter = $site->children()->listed()->pluck('tags', ',', true);
?>
<div class="label"><div class="title" onclick="location.href='<?= $site->url() ?>';"> Notes on</div></div>
<select id="menu-desktop" class="menu-desktop" onchange="window.open(this.value,'_self');">
<option selected="" hidden="">… <?php echo html($tag) ?></option>
<?php foreach ($filter as $filter): ?>
<option value="<?= $site ?>/tag:<?= $filter ?>">
… <?= $filter ?>
</option>
<?php endforeach ?>
<option value="<?= $site ?>/us/tag:us">
… us
</option>
<option value="<?= $site ?>/imprint/tag:imprint">
… imprint
</option>
</select>
and here is the code for the “thumbnails” of the items that then link to their pages, where the issue is with the href
<?php
$works = $site
->children()
->not('error')->not('home');
if($tag = param('tag')) {
$works = $works->filterBy('tags', $tag, ',');
}
?>
<div class="works">
<?php foreach ($works as $work): ?>
<div class="worksItems" id="<?= $work->Uuid() ?>">
<a href="<?= $work->url() ?>#<?= $work->Uuid() ?>">
<?php if($image = $work->bild()->toFile()): ?>
<img style="width:100%" src="<?= $image->url() ?>" alt="">
<?php endif ?>
<div class="hoverBox">
<div class="workTitle"><?= $work->title() ?></div>
</div>
</a>
</div>
<?php endforeach ?>
</div>
thank you for your help!