I’m not even sure if this is a Kirby issue but I’m at a bit of a loss with it. I have four categories: “Design”, “Strategy”, “Content”, and “Code”. I’ve built a filter that uses JS to return results based on the URL parameter and it all works fine except for the “Content” filter. I know “content” is a protected word in Kirby, but I don’t think that’s what’s causing the issue. Is there a problem with using the word ‘content’ as a parameter on an input? I can’t find any info about that.
Here is how I’m creating the checkboxes
<?php
$items = ['Design','Strategy','Content','Code'];
foreach($items as $item): ?>
<label class="radio" for="<?= Str::slug($item) ?>">
<input type="checkbox" id="<?= Str::slug($item) ?>" name="categories[]" value="<?= $item ?>" <?php if($ucategories){e(in_array($item, $ucategories), 'checked');}; e(!in_array($item, $acategories), 'disabled'); ?>>
<div class="radio__label">
<span><?= $item ?></span>
</div>
</label>
<?php endforeach ?>
I’m using a multiselect field which adds the correct tags to the content file, eg.:
Categories: Design, Code, Content
And I get the parameters like this in JS:
const formData = new URLSearchParams(new FormData(form)).toString();
let url = `${window.location.href.split('?')[0]}.json?${formData}`;
let pushurl = `${window.location.href.split('?')[0]}?${formData}`;
Everything works as expected except “Content”. If I change everything to “Contents”, it works, but that’s not what I need it to be. Does this word need escaping somewhere? Has anyone came across this issue before? Am I going mad?
Edit: Also, if I add the category straight to the URL, it works and filters correctly…
projects?view=case-studies&categories%5B%5D=Content