Need help w/Custom Memberdata - Birthdays and date format
I added birthday (type=Date) to portal_memberdata in the ZMI for my Plone site. I edited the My Preferences form to include Birthday. I then created a custom python script called getMember: roster=[] for member in context.portal_membership.listMembers(): roster.append( { 'id':member.getUserName() , 'email':member.email , 'birthday':member.birthday , 'fullname': member.fullname }) return roster And then I use some of the output of that script in a page template using the following: <table> <tr tal:repeat="member here/getMembers"> <td tal:content="string:${member/fullname}">Column 1 dummy data</td> <td tal:content="string:${member/birthday}">Column 2 dummy data</td> </tr> </table> The problem is that I cannot get the birthday date string data formatted with just Month, Day and I have no idea as to how to sort this data my month. --Jim __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Jim Barbara wrote:
The problem is that I cannot get the birthday date string data formatted with just Month, Day
Look into the strftime method. It can format dates however you like to see them.
and
I have no idea as to how to sort this data my month.
As for sorting, you can call a list objects sort function and pass a comparison function as an argument. Define this sort function in the same script as your getMember script, if you'd like. Something like: def memberCompare(a, b) : #you'll get two list items from roster as a and b. # compare and return -1, 0 or 1. ...rest of getMembers..then... return roster.sort(memberCompare) Hope that helps.
participants (2)
-
Jim Barbara -
Kevin Carlson