1

I have a section where most entries have a category assigned to them, but a few ones have no category at all.

I need help how to connect these entries' URLs to my entry template.

So far I used a route to catch these cases and assign them to the entry template:

"Route URLs like section/slug to template /section/_entry."

Then I realised that this also catches all entries that have a category, so both these URLs would be valid: /section/category1/slug1 and /section/slug1

But all entries with a category assigned to them should raise a 404 if their category is missing from the URL.

This looks like a common scenario, but so far I only found a solution where those entries are given a default category.

How can I handle my case?

  • Do you use custom routing or entry/section routing? I don't really understand your issue to be honest because your routes are set in the section settings there is only one route for each entry. An entry doesn't have multiple different routes – Robin Schambach Oct 30 '18 at 10:21
  • @Robin, I'm using entry/section routing. The URI entry is "{category.inReverse().one().uri}/{slug}" (as some entries have sub-categories), the template entry "mysection/_entry". I also have a custom route for those entries without a category: "mysection/slug" which I route to a template that redirects depending on the presence of a category. – Crafty Cat Nov 20 '18 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.