You are here: Home / Blog / posts / Pixelworkers of CAES DO / Collection of events

Collection of events

by pgang — published Apr 19, 2011 11:10 AM, last modified Jan 28, 2014 02:54 PM
Call me crazy, but sometimes I like using collection portlets for events (i.e. events of a certain category) or event-type-clones.

This doesn't always bode well though: by default collection portlets show the last modified date of an item, not the event start date as you may be expecting. Luckily, it's an easy fix, since we have a model in the events portlet. Here's the plan:

The code

Really all it is is a tal statement to display the object start date. The tal:condition part of it checks to make sure the item has a start date, before trying to display it. I like keeping it in a span to give it a class for styling purposes.

<span class="portletEventDate" tal:condition="obj/start" tal:content="python:toLocalizedTime(obj.start)">
   May 5
</span>

Another thought is you could just swap the portletItemDetails date (currently obj.Date) to just be the start date (obj.start) but this doesn't fly if you need to use collection portlets elsewhere on your site for non-events.

By the way, this all goes into the collection.pt template which can be found in portal_view_customizations. I put it the line after <span class="portletItemDetails"...> ... </span> but you can put it wherever you feel is useful. Enjoy!

p.s. We've been getting a crap ton of spam. Like, gran turismo cheats and all sorts of diet pills and propecia fo' life. Until I can get around to putting PloneCaptcha or something on here, comments are on lockdown!

When:

Where:

Contact