I’m trying to filter a “projects” page by tags and its working great until I get to a tag which includes a forward slash. I understand this can’t be used directly in the URL but would like to encode and decode it to be able to keep it as a tag name. The current behaviour is that the “Film / Documentary” tag is added to the query string as “projects/tags:Film+%2F+Documentary”. I am using the urlencode() and urldecode() functions which work well with all other tags until this one with the slash.
Thanks in advance,
That should actually work. Could you please post your code?
This is the code that creates the link:
<?php foreach($artstags as $tag): ?>
<a href="<?= url('projects', ['params' => ['arts' => urlencode($tag)]]) ?>">
<?= html($tag) ?>
<?php endforeach ?>
I have noticed that this actually does read as a slash - but as you can see above, it tries to render a different page (as in the / acts as part of a file path). Any ideas?
I suppose what I’m wanting is to swap out the ‘/’ for something else and then parse that as a slash again when searching the tags.
Hm, weird. You could also try
rawurldecode() instead. Don’t know if that makes a difference in this case but maybe worth a try.
Raw seems to produce this instead - which unfortunately still doesnt help - thanks for the suggestion.
Hm, then I don’t know, maybe it’s server specific somehow, because both versions work in my environment.
Ahh Okay, no worries, thanks for trying!
So better do some string replacing.
Hey! Thanks for that. I did indeed end up doing some string replacement and it all worked out in the end!
Appreciate your time!