I’ve been working on adding some things to a client’s EE 1.6.8 site and one of the requests was to add a sort by year drop-down to one of the article pages.
here:
http://www.earth-policy.org/press_room/in-the-news/web
The page is currently being sorted by setting the uri segment_3 to either audio, video etc. and then using the populated segment_3 and the variable media_type set for each entry to display the correct entries below.
I set up the year drop-down the same way, adding the year to segment_4 and keeping segment_3 and then I set the year parameter in the exp:weblog:entries tag bellow to {segment_4}. This all works fine except it is doing the sorting based on the entries date and apparently I need to sort based on a created variable date, “publication_date”.
So the real issue here is I need to figure out how to dynamically make the content filter based on the publication date year and not based on the actual entry date.
Here’s the code below that works for sorting by entry date just to get an idea of how it’s structured or set up… (also I’ve just been hired to make this part work, I didn’t build the site out this way to begin with and I don’t know if I can really change a lot)
Dropdown:
<form name=“typemenu”>
<select name=“seltype”>
<option value=”“>—Select Media Type—</option>
<option value=”/press_room/C69”>—Show All Types—</option>
<option value=”/press_room/in-the-news/print”>Print</option>
<option value=”/press_room/in-the-news/audio”>Audio</option>
<option value=”/press_room/in-the-news/video”>Video</option>
<option value=”/press_room/in-the-news/web”>Web</option>
</select>
<select name=“orderby”>
<option value=”“>—Select Year—</option>
<option value=”/press_room/in-the-news/{segment_3}”>—Show All Years—</option>
<option value=”/press_room/in-the-news/{segment_3}/2011”>2011</option>
<option value=”/press_room/in-the-news/{segment_3}/2010”>2010</option>
<option value=”/press_room/in-the-news/{segment_3}/2009”>2009</option>
<option value=”/press_room/in-the-news/{segment_3}/2008”>2008</option>
<option value=”/press_room/in-the-news/{segment_3}/2007”>2007</option>
<option value=”/press_room/in-the-news/{segment_3}/2006”>2006</option>
<option value=”/press_room/in-the-news/{segment_3}/2005”>2005</option>
<option value=”/press_room/in-the-news/{segment_3}/2004”>2004</option>
<option value=”/press_room/in-the-news/{segment_3}/2003”>2003</option>
<option value=”/press_room/in-the-news/{segment_3}/2002”>2002</option>
<option value=”/press_room/in-the-news/{segment_3}/2001”>2001</option>
<option value=”/press_room/in-the-news/{segment_3}/2000”>2000</option>
</select>
</form>
Inside the select tags there is also an onchange with “location=document.typemenu.orderby.options[document.typemenu.orderby.selectedIndex].value;”
for both.
Opening of weblog tag:
{exp:weblog:entries weblog="epi_in_the_news" category_group="not 999" orderby="publication_date" sort="desc" limit="1000" year="{segment_4}”}