Filter does not work on a server when special characters (space, ä, ö, ü) are used

Hello guys,

I know this might probably be not a Kirby problem, but maybe I can solve this problem within Kirby. On my site, I have a very easy tag filter section which works perfectly on my localhost and on my online test server, but does not on the client server.

On the client server, the filter works when filtered by “normal” words like “Bochum”. But when the word has an german umlaut like “Köln” or a space like “Duisburger Filmwoche”, the filter doesn’t print results.

Because I don’t know how a server or PHP works, I have no idea where to search for a solution. Can I solve this within Kirby or should I contact the support? If yes, what exactly should I ask them?

(I can’t show any code snippet, because I don’t know which one.)

Thank you!

You can solve this with urlencode() (in the links) and urldecode() in the controller of your filters

1 Like

Okay now i can show yome code. In my template I have:

<?php foreach ($page->hosts()->split() as $host): ?>
<?php $url = url($page->url(), ['params' => ['host' => $host]]) ?>
  <li><a href="<?= urlencode($url) ?>" ><?= $host ?></a></li>
<?php endforeach ?>

and where do I have to insert the urldecode() in my controller?

return function($page) {

$host = param('host');

$events = $page
  ->children()
  ->when($host, function($host) {
    return $this->filterBy('host', $host);
  })

thanks!

If you use url() method with the params array, the url is already encoded, so no need to do this again in the next line.

$host = urldecode(param('host'));

This was it! Thank you <3