2012/12/28

Add Author Name to Collection Portlet

By default the Plone collection portlet will display item's title only. We might want add other info for the item listing. Here is an example to add Author Name in plone.portlet.collection/collection.pt:

     itemUrl    python:useView and obj.getURL() + '/view' or obj.getURL();
-    item_icon python:getIcon(obj);"
+    item_icon python:getIcon(obj);
+    itemCreator python:obj.getObject().Creator();
+    author python:context.portal_membership.getMemberInfo(itemCreator);
+    authorName python: author and author['fullname'] or itemCreator"

Note that using Creator() instead of Creator, or you will fail when passing itemCreator to portal_membership.getMemberInfo(). This is adapted from codes in plone.app.layout/viewlets/content.py

No comments: