curios-one wrote:
Thank you very much Jean-Marc,
I would really appreciate if you could send me the code.
OK, see the attached files. They do more than you need, there is a field
called 'alphabetical_order' on the section which is either True or False.
then it is passed to getFolderItems():
sort_by = alphabetic_order and 'title' or ''
folderItems = context.getFolderItems(context_obj=context_obj,
show_docs=1,
max_title_words=10, display_hidden_folders=0,
display_valid_docs=1, sort_by=sort_by)
you can sort by 'date', 'title', 'author', and invert the sorting order
with 'sort_direction' = 'desc' or 'asc'
see:
CPSPortlets/skins/cpsportlets_widgets/getFolderItems.py
I also have another question, how is used getCustomDisplayParams.py?
this one belongs to CPSDefault, I'm not sure about what it does.
Thanks again
C.
you're welcome /JM
##parameters=context_obj=None, rel_depth=1
from Products.CMFCore.utils import getToolByName
utool = getToolByName(context, 'portal_url')
info = {}
folderish = context_obj.isPrincipiaFolderish
container = folderish and context_obj or context_obj.aq_inner.aq_parent
context_rpath = utool.getRelativeContentPath(context_obj);
depth = len(context_rpath);
current_level = depth + 1 - rel_depth
alphabetic_order = False
try:
alphabetic_order = container['alphabetic_order']
except KeyError:
pass
sort_by = alphabetic_order and 'title' or ''
hide_items = False
try:
hide_items = container['hide_items']
except KeyError:
pass
trailItems = context.getBreadcrumbsItems(display_site_root=1, first_item=0,
display_hidden_folders=1, parent=not folderish)[int(rel_depth):]
if hide_items:
folderItems = []
else:
folderItems = context.getFolderItems(context_obj=context_obj, show_docs=1,
max_title_words=10, display_hidden_folders=0,
display_valid_docs=1, sort_by=sort_by)
style = {
0: 'padding-right:3px',
1: 'text-transform:uppercase;padding-right:3px',
2: 'padding-right:3px',
3: 'padding-right:3px',
4: 'margin-left:10px;padding-right:3px',
}
listingstyle = {
0: 'border:none;padding-right:3px',
1: 'border:none;padding-right:3px',
2: 'border:none;padding-right:3px',
3: 'border:none;padding-right:3px',
4: 'padding-left:10px;border:none;padding-right:3px',
}
for item in folderItems:
item['selected'] = item['selected'] and 'selected' or ''
info['folderitems'] = folderItems
info['folderItemStyle'] = listingstyle[min(depth, 4)]
info['folderItemClass'] = 'h%s' % min(6, depth+1)
level = 0
for item in trailItems:
level += 1
item['style'] = style[min(level, 4)]
item['class'] = 'h%s' % min(level, 6)
item['selected'] = (folderish and (level == current_level)) and 'selected' or ''
info['trailitems'] = trailItems
return info
_______________________________________________
cps-users mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/cps-users