ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Help w/ Grouping Entries by Date (Day)?

June 26, 2014 6:16pm

Subscribe [2]
  • #1 / Jun 26, 2014 6:16pm

    msmith29063

    75 posts

    I need to group entries by date (day). And I don’t think {date_heading} will work for me. I had to build slideshow slides out of the entries and the {switch} and {count} variables don’t work when {date_heading} is used.

    Here’s what it looks like:

    {exp:channel:entries channel="events" start_on="{current_time format='%Y-%m-%d 00:00'}" show_future_entries="yes" sort="asc" limit="9999" dynamic="no"}
     {switch='<ul class="slide">|||||||||'}
      <li{switch=' class="first"||||'}>
       <a{if segment_2 == url_title} class="active"{/if} href="{title_permalink='events/index'}" title="{title}">
        <h5>{entry_date format="%D. %F"}</h5>
    <p>    </p><h6>{entry_date format="%j"}</h6>
    <p>   </a><br />
      </li><br />
     {if count == total_results}<br />
     </ul><br />
     {if:else}<br />
     {switch='|||||||||</ul>'}<br />
     {/if}<br />
    {/exp:channel:entries}

    Any recommendations? Also—what would the link look like to the page with the date passed in the URL for displaying entries for that day?

    Thank you for your help.

  • #2 / Jun 27, 2014 1:06am

    Rob Allen

    3114 posts

    I’m slightly confused, what is the exact problem you’re having?

  • #3 / Jun 27, 2014 1:34am

    msmith29063

    75 posts

    This is basically an events calendar. I’m outputting the entries into a events listing slideshow.

    The issue is when there are multiple event entries for the same day. So I need to be able to group entries by date (day). So if there are two events for July 2—July 2 should only appear in the listing once. Then when you click the link—it takes you to the view page that outputs both entries for that day.

    The code I currently have outputs a date entry for each event. So July 2 appears in the listing twice—since there are two events on that day. And the link takes you to the view page for that one event.

  • #4 / Jun 27, 2014 2:54am

    Rob Allen

    3114 posts

    Hmm date_heading tag should work here, using date_heading and date_footer set to “daily” something like this should loop events grouped by each day that has events…

    {exp:channel:entries channel="events" start_on="{current_time format='%Y-%m-%d 00:00'}" 
    show_future_entries="yes" sort="asc" limit="9999" dynamic="no"}
    
    {date_heading display="daily"}
      <h1>{entry_date format="%Y %m %d"}</h1>
      <ul class="slide">
    {/date_heading}
    
      <li>
       <a{if segment_2 == url_title} class="active"{/if} href="{title_permalink='events/index'}" 
    title="{title}">
        <h5>{entry_date format="%D. %F"}</h5>
    <p>    </p><h6>{entry_date format="%j"}</h6>
    <p>   </a><br />
      </li></p>
    
    <p>{date_footer display="daily"}<br />
      </ul><br />
    {/date_footer}<br />
    {/exp:channel:entries}

  • #5 / Jun 27, 2014 8:20am

    msmith29063

    75 posts

    I appreciate your reply. But this is not what I’m trying to do. I don’t need to add a heading and create a slide for each date. I need to display ten dates per slide and add the “first” class to every fifth event. In this regard—my code already does this. The issue is that when I use {date_heading} to group events, the layout is broken because the {switch}‘s and {count} conditional are still based on the number of entries, not the number of grouped dates.

  • #6 / Jun 28, 2014 7:10am

    Rob Allen

    3114 posts

    Ok so is a “date” a single EE entry?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases