How to get an annual list of entries in ExpressionEngine?

So, I need to get a list of years of all the entries to use in the drop down list. Basically, I need to group the record every year and list the grouped year.

something like this: http://cl.ly/image/0T1M0j1p0R3f

thanks

+8
expressionengine
source share
2 answers

This addon for EE1 or EE2 will give 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, records with the parameter year = "" are limited in your template:

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

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

Configure the drop-down list as follows:

 <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 the landing page, you'll do something similar to display your entries based on the year:

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

And use some jQuery to redirect to your summer pages:

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

If you want to do this via javascript instead of jQuery checkout in this article

+6
source share

All Articles