Hi all! I’m a bit new to EE, figured I’d start things off with a bang.
THE PROBLEM: I have a news template that wants to do non-standard entry aggregation. If you request posts for a given Monday or Tuesday, you should see everything from that Monday and Tuesday. Wednesday or Thursday returns posts for Wednesday and Thursday, and Fri/Sat/Sun are grouped similarly. I currently have some logic in place that pulls the date out of the segment data (or just assumes “today”) and sets start_on and stop_before appropriately. Here’s the issue: If a user views a past date for which there are no posts, we just redirect them to the latest post. However, it is possible for there to be no content in the latest date range (eg you view on Monday but the latest available content is from Friday). In this case, we have to 1) find the most recent entry 2) build the start_on/stop_before range based on that entry’s post date, so we can pull in all the posts for that range.
Here’s my first stab at the process:
The problem is that this requires some ugly (and impossible) mash of input and output PHP processing. I’ve looked at using the EE API to try to do the necessary lookups in PHP instead of using exp:channel:entries, but no luck so far.
Any advice, alternate approaches, etc would be greatly appreciated!
Moved to Development and Programming by Moderator
Hi Kenneth,
This sounds like a good candidate for a little custom plugin. Inside it, you can grab what you need from the URI, and have it look at just the exp_channel_titles table (very shallow) to determine what entry ids to display. Then, you can hand back the appropriate entry ids in a tag you’d pass as a parameter to exp:channel:entries, like
{exp:channel:entries channel="comics" entry_id="{exp:my_plugin_output}" }
content
{/exp:channel:entries}Make sense? That way there’s only one call to the full-blown channel entries tag as well, and you’re always telling it to display the right entries. I’m sure there’s other ways to go about this as well, but hopefully that gets you pointed in the right direction?
Thanks for the suggestion! I tried moving all my logic into a plugin, but it looks like I can’t use an EE tag within an EE tag like you suggest. Is there another way I should be approaching it, or do I have something set up wrong? I have a plugin date_util that I’m using along the lines of
{exp:channel:entries start_on="{exp:date_util:start_date}” stop_before=”{exp:date_util:stop_date}”}
and with template debugging on, I can see that the entries tag is just reading the literal “{exp:date_util:start_date}” for that value.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.