0

Using Expressionengine 3.5.11

I need to display the entries from a specific channel, thus '/entry-url', this is obviously not difficult, however I also need to display an index page for a couple of other channels at the same URL level, thus

'/news'

'/services'

which would then work thus:

'/news/{entry}'

'/services/{entry}'

I could use an 'if' statement to check for these two first, and if they are not part of the request, then direct the user to the specific channel page, but this would require a change to the if statement every time a new channel is added, I'd like a solution where new channels can be added with no need to update the if statement.

I'm pretty sure this isn't possible as specific filters are required to route to 'news' and 'services', or is there a way?

0

If you have channels dog and cat that you want to be processed by (the same) different template to the default, you can add a template route for the different template you want to use that looks like this:

/{big:regex[(dog|cat)]}

You can get clever than this, and I imagine write a template route definition that generalises the case you are working with so that if you added a new channel the route would automatically work out what to do - but a general heads-up, the code EE3 uses to process template routes is quite buggy and anything even vaguely complex seems to break: so it is quite possible that you would end up wasting a lot of time to end up where you started from... and against this conditionals in templates become an attractive option (I've been there...).

Fingers crossed that this is one of the areas that V4 will fix.

Anyhow, HTH

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.