Hi guys
I’m looking for some help with a problem on a client site.
I have a weblog for events and a custom date field for the date the event occurs.
What I want to be able to do is have a list in a sidebar with an archived list of previous events like this:
PREVIOUS EVENTS Dec 2010 Nov 2010 Oct 2010 Sep 2010 …
with each date a link which goes through to a page with a list of events for that month.
I can achieve this by using the entry date but not a custom date field - can anyone point me in the right direction.
Will I have to use some sort of custom database query?
(I’m using EE 1.6)
Many Thanks
Yes you’d need to use a custom query and some PHP. Basically, you’d loop through your entries keeping track of which month+year combinations actually exist, then format and sort the text, then create a link to a template which accepts a date as a segment variable which you then plug into the search parameter of your exp:channel:entries tag pair.
Basically, it’s not something we can quickly show you, but it’s possible for you to do. For the sites I work on with my team, we always try to use entry_date and expiration_date for events channels simply because it just makes things so easy. So I would try to figure out how to use those dates for your site, but I understand if you’re unable to use those.
Also, if you have a lot of data that is coming from a few different channels that needs to be processed, you could output the data in JSON format in the template, and then use javascript sorting on the page itself.
I just went through this on a project where I had to sort a bunch of events based on different metrics… JavaScript ended up being much faster than having EE pre-sort it all, plus EE wouldn’t sort my custom fields.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.