We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom entry aggregation

Development and Programming

PA Webmaster's avatar
PA Webmaster
4 posts
14 years ago
PA Webmaster's avatar PA Webmaster

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:

  • Generate the target range based on segment data using PHP
  • Do a shallow exp:channel:entries (disable pretty much everything) to see if entries for the requested range exist. ** If true, display the entries and go home happy ** If false, do a shallow exp:channel:entries to find the single most recent post. Use this date to generate a new target range (using PHP) with which to aggregate and display entries.

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

       
Brandon Jones's avatar
Brandon Jones
5,500 posts
14 years ago
Brandon Jones's avatar Brandon Jones

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?

       
PA Webmaster's avatar
PA Webmaster
4 posts
14 years ago
PA Webmaster's avatar PA Webmaster

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.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
14 years ago
Sue Crocker's avatar Sue Crocker

Hi, Kenneth.

Since you’re working with making a plugin, I’m going to move this to the Developer forum for additional community support.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.