0

Have

  • events channel
  • have 10 entries (the channel can have varying range of entries for example it has 10)
  • have a date field called event_start_date
  • ex. current date is 2016-05-30

Desire - dynamically display last 6 entries in this sorted list - this list can have

List

  • 2016-02-08
  • 2016-03-01
  • 2016-03-29
  • 2016-05-02
  • 2016-05-15
  • 2016-05-30
  • 2016-09-12
  • 2016-10-24
  • 2016-11-01
  • 2016-12-06

Desired Results:

  • 2016-05-15
  • 2016-05-30
  • 2016-09-12
  • 2016-10-24
  • 2016-11-01
  • 2016-12-06

Unsure how to grab the last 6 entries always in a channel. Any help would be greatly appreciated.

0

It's quite straight forward, just use the sort order (default is desc) and limit parameters.

{exp:channel:entries channel="my-channel" sort="asc" limit="6"}
    ...
{/exp:channel:entries}
| improve this answer | |
  • Using sort="asc" will provide the dates in the reverse order to that required. To get them in the right order will either require a tiny bit of inefficient processing - loop through the whole list and only display those that are within 6 of the total number of entries in list - or capturing the reverse list in a storage mechanism (e.g. Stash) and putting them out from there in reverse order. – JCOGS Design May 17 '16 at 16:50
  • i'm looking to get the last 6 entires of the list the in order list above form date 2016-05-30. thanks but not exactly the answer to the question. – Lacer May 17 '16 at 16:59
0

ok had to use the query option but here's the code

{exp:query sql="SELECT * FROM (SELECT * FROM (SELECT * FROM exp_channel_data WHERE field_id_13 > '1' ORDER BY field_id_13 asc LIMIT 6) AS tableStore) AS tableStore ORDER BY field_id_13 DESC"}
        {field_id_13 format='%Y-%m-%d'}<br>
{/exp:query}
| improve this answer | |
0

add the search parameter:

search:event_start_date=">=2016-05-30"

to the channel entries tag.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.