Hello hello,
Starting with Blogprint as the base for a site, I am having trouble getting multi-word tags with a space in them (eg. Self Organisation) to generate a working link. Single words working fine.
Reading other posts I think it’s something to do with urlencode
and urldecode
, but am still struggling after many suggestions.
In the controllers:
if(isset($data['tag'])) {
$tag = urldecode($data['tag']);
$posts = $posts->filterBy('tags', urldecode(param('tag')), ',');
$archiveTitle = ' for tag "' . $tag . '"';
}
In the tags list:
<?php $tags = getTagsArchive(); if($tags->count() > 0): ?>
<ul>
<?php foreach($tags as $tag): ?>
<li>
<a href="<?= $site->url() ?><?php echo $tag->url() ?>">
<?php echo ucwords($tag->name()) ?>
</a>
</li>
<?php endforeach ?>
</ul>
This currently gives links such as example.com/tag/self+organisation which comes up with no results. Trying to put urlencode into the tags list (and other suggestions I found) stop the list from appearing at all, give the base url of the site, and other non-working scenarios.
I’ve been reading and trying everything I can find on here and still seem to be doing something wrong, some fresh eyes would be amazing.
Thank you