1

I'm using EE for a few years now and pretty often I'm setting up segment variables to dynamically configure tags - like this:

{exp:channel:entries
    channel="{segment_2}"
    entry_id="{segment_3}"
    author_id="{segment_5}"}

{/exp:channel:entries}

Although this is working fine, it tends to make URLs pretty long, which I despise. :(

Now, I've already tried native template routes as well as Resource Router, Stash and other third-party options, but I can't figure out an alternative way to set these dynamic parameters reliably.

Am I missing something?

Is there another method like maybe setting variable across page-loads?

5
  • 1
    I'm struggling to see how this would work or why you'd want this URL structure - for example if you have segment 3, you have the entry, so segment 5 is irrelevant, also if you have the entry ID, the channel is irrelevant. Can you give more details of the objective of content structure and example URLs which would be relevant. Commented Jun 12, 2014 at 12:11
  • Sorry, this was just to explain what I was talking about, not an actual working example. I'm looking for best practices in general, not a solution to a specific problem. Thanks for your input though! Commented Jun 12, 2014 at 12:43
  • Why set them dynamically to that degree? Are you using a single template for multiple channels? Commented Jun 12, 2014 at 13:15
  • Yes, exactly. I'm using one template for two channels. Peter inspired some ideas though, which I hadn't looked into. So, thanks for that already! :) Commented Jun 12, 2014 at 14:08
  • With resource router you could set RR-variables and pass those into the channel entries tag, instead of the segment-variables directly. That way in Resource Router you have some control over everything (e.g. store search stuff in session etc.) Commented Jun 16, 2014 at 9:02

2 Answers 2

1

The Channel Entries tag can also take Dynamic Parameters. You specify which ones you would like to allow to be configured from GET/POST with the dynamic_parameters= Channel Entries tag parameter.

If you need maximum control—essentially control of the tag itself—via the URL, this is the way to go. It's not for every use case, as @james-smith points out above, the Channel Entries tag does a lot for you automatically without usurping control of the tag. But in instances where you want to usurp that control to the URL, it can be very handy.

0

Are you aware of the dynamic nature of the channel:entries tag? It won't handle author_id, but by default it will automatically filter itself if it detects a url_title, entry_id, category_url_title/category id, dates, or pagination markers in the URL. Here's a full explanation:

http://www.jamessmith.co.uk/articles/expressionengine_url_schematic

You need to be a little bit careful about passing segment data directly into a channel entries tag as you could accidentally expose content that was meant to be private.

Alternatively, if you're looking for more advanced filtering, try Reefine.

1
  • Yeah, I knew about that and I'm actually using Reefine. Thanks for pointing it out though. I guess, after hours of coding, I was just a little lost. Now, I've already reduced my segments from 7+ to 4 and it's turning out quite nicely. :) Commented Jun 12, 2014 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.