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

showing 3 records within a condition

How Do I?

Aj755's avatar
Aj755
1 posts
3 years ago
Aj755's avatar Aj755

Hi Probably a bit of a basic question but I am fairly new to expression and am trying to only display 3 records within a condition and limit or count dont work for this. My code is

{exp:channel:entries channel="events" dynamic = "0" orderby="date_from" sort="asc" }
   
           {if date_from > current_time}
show record
{/if}
{/exp}

However if I use this the code shows 6 current records as there are 6 future dates. However I want only to display the 3 nearest upcoming events and limit wont work nor will count as not the first three records. Would normally use i++ to count up but not sure how this works in EE. Any ideas how to add a counter to pick 3 events and then stop Thanks

       
Andy McCormick's avatar
Andy McCormick
322 posts
3 years ago
Andy McCormick's avatar Andy McCormick

I believe you can use start_on="tomorrow" along with limit. This will only list entries that are dated for tomorrow or later. https://docs.expressionengine.com/latest/channels/entries.html#start_on

{exp:channel:entries channel="events" dynamic = "0" orderby="date_from" sort="asc" start_on="tomorrow" show_future_entries="yes" limit="3" }

       

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.