This is probably a weird question but I’ll ask it anyway.
I’m coding a site and I have a few categories I want to use to filter the content.
Now I have a folder structure for the single page that looks like this
home/year/product
I assign the category using a select field…
…that I popolate fetching values from a tag field in the stored on the home template.
This way if I want to add a new category I just add a new tag on the home page and I’m done.
Now, what I want to do is to have clean urls across the site.
For example when visiting /tech/
I want to see only the products with that particular category.
I already done all this and my only problem is with the route.
The action part of the route is ok and is working fine.
'action' => function($category) {
return array('home' , ["category" => $category]);
}
What I’m trying to find a solution to is the pattern.
I know I can use something like
'pattern' => "(:any)"
But this is obviously going to affect basically every single page of the site.
Also I know I can do something like this:
'pattern' => "(fashion|tech|misc)"
In order to get only the routes that I want but this is clearly not dynamic.
So my question is, is there a way to have some sort of dynamic route that acts like this (foo|bar|baz)
but I can set using values coming from a field? Maybe by passing an array or a formatted string.
I tried a bunch of things but none of them seems to work