8

I need to get list of years of all entries for use in dropdown. Basically I need to group entry date by year and output grouped year in a list.

something like this: https://dzwonsemrish7.cloudfront.net/items/2G161x0v1U0d2U0k133a/2012-10-23_19-50-41.jpeg?v=9c5b44e8

Cœur
  • 37,241
  • 25
  • 195
  • 267
Davor
  • 400
  • 5
  • 12

2 Answers2

12

This addon for EE1 or EE2 will get you what you need: http://devot-ee.com/add-ons/yearlist

{exp:yearlist channel="yourchannel"}
         <a href="{path=archive}/{year}">{year}</a>
{/exp:yearlist}

Then in your template limit the entries with the year="" parameter:

{exp:channel:entries channel="news" year="{segment_2}"}
    <h1>{title}</h1>
    {body}
{/exp:channel:entries}
Anna_MediaGirl
  • 1,120
  • 13
  • 31
6

Using this add-on http://devot-ee.com/add-ons/yearlist you could do this:

Setup your dropdown like so:

<form name="yourform" action="">
    <select id="yourselect" name="yourselect">
        {exp:yearlist channel="yourchannel"}
            <option value="{path=archive}/{year}">{year}</option>
        {/exp:yearlist}
    </select>
</form>

On your landing page you'd do something like this to display your entries based on year:

{exp:channel:entries channel="news" year="{segment_2}"}
    <h1>{title}</h1>
    {body}
{/exp:channel:entries}

And use some jQuery to redirect to your year pages:

<script type="text/javascript">
    $('#yourselect').change(function() {
        window.location = $(this).val();
    });
</script>

If you'd like to do it via javascript instead of jQuery checkout this article

Natetronn
  • 466
  • 3
  • 12
  • Thanks! The addons is working just as stated, now I only need to find a way to change the {year} var as Dynamo uses the same for its results – Davor Oct 24 '12 at 01:57
  • 1
    Post another question and we'll help with that change too. – Anna_MediaGirl Oct 24 '12 at 02:24
  • I finished the form finally and tested it finally hehe. I will not hesitate to post again for something. thanks MG :) – Davor Oct 24 '12 at 12:24