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.

Ordering entries by date and grouping seperately

October 17, 2012 7:14am

Subscribe [2]
  • #1 / Oct 17, 2012 7:14am

    Scott Harrington

    85 posts

    Hi All, I’m sure I’ve approached this before somewhere and have been through all my references but cant seem to locate anything which relates.

    Basically I’ve created a gallery based on a basic channel and wish them to be displayed in groups, based on the relevant month and year - for example January 2012 would show all the January images, February 2012 to show Februarys and so on.

    I can get these to display in date order no problems, however I would like each group to have a header to seperate each group and not have them just generally listed on one page in order.

    For example, using the code below…what would be the best method to throw the header tag within the loop to show just the once before each months entries and repeat thereafter?

    {exp:channel:entries channel="main_gallery" sort="desc|asc" orderby="entry_date" limit="60"}
    <h2>*** ENTRY MONTH AND YEAR TO GO HERE TO HIGHLIGHT RELEVANT ENTRIES ***</h2>
    <p><article class="{switch='image-one|image-two|image-three|image-four|image-five|image-six'}"><br />
    {sized}<br />
    {name}<br />
    </article><br />
    {/exp:channel:entries}

    The only way I could think of was using the archive method but would that be sufficient?

    Any help would be appreciated.

    Thanks

     

     

  • #2 / Oct 20, 2012 9:08am

    John St-Amand

    865 posts

    Based on how you’ve described it, I believe the date heading tag pair is what you would be looking for. It outputs only once for the interval you specify (yearly, monthly, etc).

  • #3 / Oct 23, 2012 12:27pm

    Scott Harrington

    85 posts

    Fantastic, found it thanks 😉

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

ExpressionEngine News!

#eecms, #events, #releases