plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
246 stars 187 forks source link

return 'random' results from a collection #2056

Closed tkimnguyen closed 6 years ago

tkimnguyen commented 7 years ago

It would be nice ™ to be able to have a collection return results in random order.

as per discussion in https://community.plone.org/t/ideas-for-showing-collection-items-in-random-order/579

davisagli commented 7 years ago

I would look at the fake getObjPositionInParent index for a model of how to implement this. It's an index object in the catalog, but it doesn't actually store anything. When you sort by it it goes and finds the original folder and returns results in the order from that folder. A "random" sort index could similarly just return a random sort value for each result.

Keep in mind this kind of thing tends to run afoul of cacheability though.

rafaeltcc commented 7 years ago

+1 for this feature. For a news site this is very important. Being able to have a collection displaying news items in a random way.

mauritsvanrees commented 7 years ago

I don't think a lot of people will want this, so this sounds more like an add-on, for example with a behavior or a portlet.

I knew I created something with random content. Okay, I found it. Haven't touched it in five years. It's not quite the same as you want, but maybe collective.randomcontent may serve as inspiration.

rafaeltcc commented 7 years ago

I can think of several use cases for this:

2017-06-09 13:55 GMT-03:00 Maurits van Rees notifications@github.com:

I don't think a lot of people will want this, so this sounds more like an add-on, for example with a behavior or a portlet.

I knew I created something with random content. Okay, I found it. Haven't touched it in five years. It's not quite the same as you want, but maybe collective.randomcontent https://github.com/collective/collective.randomcontent may serve as inspiration.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/plone/Products.CMFPlone/issues/2056#issuecomment-307442643, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyyM63KEF6D8IjrsSp1hvAEBArjDztTks5sCXj_gaJpZM4NhVWx .

jensens commented 6 years ago

IMO this should be an addon. It is quite simple: provide a (fake) index returning all ids in random order. thats all.

jensens commented 6 years ago

FYI: I closed this, because it's formal not a plip, just a rough idea.