集合的多级排序

发布于 2024-10-29 19:20:55 字数 88 浏览 1 评论 0原文

我将如何向集合添加另一个级别的排序。

示例:房地产网站有待售房产列表。列表是使用集合来实现的。已售房产需要位于列表底部,但其余房产需要按价格排序。

How would I go about adding another level of sorting to collections.

Example: A real estate site has listings of properties for sale. The listings are achieved using Collections. Sold properties need to be at the bottom of the list but the rest need to be sorted by price.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一抹微笑 2024-11-05 19:20:55

http://plone.org/products/collective.flexitopic

在 javascript 领域执行此操作。如果对你来说没问题的话。否则这个索引:

http://www.dieter.handshake.de/pyprojects/zope/ #ManagableIndex

可以帮助您创建一个新字段来对集合进行排序。

另一种方法可能是为已售房产提供负价格而不显示它,这样排序就会按预期进行。

http://plone.org/products/collective.flexitopic

does this in the javascript land. If it ok for you. Otherwise this index:

http://www.dieter.handshake.de/pyprojects/zope/#ManagableIndex

could help you to create a new field to sort the collection.

Another approach could be to give to sold properties a negative price and not display it, so sorting would work as expected.

风柔一江水 2024-11-05 19:20:55

如果没有额外的编码,您就无法做到这一点。检索目录查询结果后,您必须手动对其进行排序,因为 Zope 目录本身不支持多级排序。根据您的结果集大小,这也可能非常低效。

如果您想走这条路线,则必须子类化 ATContentTypes.content.topic.ATTopic 类并重写 queryCatalog 方法,或者创建主题视图的新皮肤版本以调用不同的方法,然后该方法依次调用 queryCatalog,以便您可以对其应用附加排序。

不用说,这需要一些 Plone 和 python 专业知识。

You can't without additional coding. You'd have to manually sort the catalog query results after retrieving them, as the Zope catalog does not support multi-level sorting by itself. Depending on your result set size, this could be quite in-effecient as well.

If you want to go this route, you would have to either subclass the ATContentTypes.content.topic.ATTopic class and override the queryCatalog method, or create new skin versions of the topic views to call a different method that in turn then calls queryCatalog so you can apply additional sorting to it.

Needless to say, this requires some Plone and python expertise.

二智少女猫性小仙女 2024-11-05 19:20:55

您可以创建嵌套集合。就像默认的事件集合一样,它有一个“过去的事件”集合。
我相信您无法在同一列表中显示嵌套集合的对象,但至少您会看到“过去的事件”大链接。

使用这种方法,您应该从初始集合中排除已售出的属性(sold 必须是目录中的索引),并仅在嵌套属性中包含已售出的属性。

You can create a nested Collection. Like in default Events Collection, that has a "Past events" collection.
I believe you can't display the nested collection's objects in the same listing, but at least you see a "Past events" big link.

With this approach, you should exclude sold properties from initial collection (sold must be an index in your catalog) and include only sold properties in the nested one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文