Making the slug lowercase without '-' in between words

Hi all

I’m still playing around with filtering by category. What I want to do now is display the categories within the url in lowercase, but I have a problem with one category which contains two words.

Basically in the url I have

<?= url('magazin', ['params' => ['category' => $category]]) ?>

I have tried doing the urlencode and urldecode which didn’t help. I also tried the ->slug() which also, doesn’t display any results back.

Any ways around this?

This already rawurlencodes the slug, so on the other end you would have to rawurldecode()

So in my controller I have

        $categories = $articles->pluck('category', null, true);

        if($category = rawurldecode(param('category'))) {
          $articles = $articles->filterBy('category', $category);
        }

Is that correct?

My url’s are still the same site.com/magazin/category;Two Words

Hm, this

<?php 
$category = 'Two Words'; 
echo url('magazin', ['params' => ['category' => $category]]);
?>

Should create this URL: http://site.com/magazin/category:Two%20Words (although FireFox hides the %20 part)…

Yep it does that, but I’m trying to make the ‘Two Words’ lower case so to make it look like http://site.com/magazin/category:two%20words.

Is that possible?

Yes, but then you have to make sure that you use that lower case word combination also when filtering, i.e. instead of comparing the stored value to the given value, you have to compare the lower cased stored value to the given value.