通过getObjPositionInParent对集合项进行排序

pab*_*abo 2 collections plone criteria

我想将getObjPositionInParent作为集合中的排序条件.我在集合视图的站点设置中将其配置为"可用".但它不可用.我忘记了什么吗?

Han*_*ing 5

你没有忘记任何事情,但在Plone中发现了一个错误.plone.app.folder中的GopipIndex用于getObjPositionInParent索引.但是,此索引类型未针对任何收集条件进行注册.Products.ATContentTypes.criteria中的条件注册表需要包含GopipIndex的映射.可能将它添加到SORT_INDICES列表是正确的做法.要从外部执行此操作,您可以执行以下操作:

# Make sort criteria available for the GopipIndex
from Products.ATContentTypes.criteria import _criterionRegistry
crit_reg = _criterionRegistry
crit_id = 'ATSortCriterion'
index = 'GopipIndex'

indices = crit_reg.criterion2index.get(crit_id, ())
crit_reg.criterion2index[crit_id] = indices + (index, )

value = crit_reg.index2criterion.get(index, ())
crit_reg.index2criterion[index] = value + (crit_id, )
Run Code Online (Sandbox Code Playgroud)