I have a ‘categories’ table that has the columns ( id, title, slug, parentid ).
I want my url struture to be something like this:
Is it possible with Yii to have the category slug be a rule in the UrlManager. I can’t seem to think of a way to do this in order to have createUrl() still be usable.
Right now I am catching all errors, checking if it is a 404, splitting up the URI and parsing the different sections. This works fine for me but I want to also be able to use createUrl() so that the urls that yii spits out will use the url setup I have designed.
As of now I have controllers for items like: "blogs, videos, podcasts, articles" and I can access items that belong to a category like:
‘/blogs/12/category-slug’ where ‘12’ is the categoryId.
But the end result I want to achieve is more like:
If anyone could give me some pointers it would be greatly appreciated. I am sure others have tried this but it would be nice to have a reference to what people think is the "correct" way to achieve the desired results.
Where’s the problem? <slug> can be used just like a standard URL parameter. So when creating your URL, you supply the slug for the URL to generate. You should maybe make sure, that ‘/’ are replaced with e.g. ‘_’ before.