Streaming live at 10am (PST)

[CMS] Random sorting


#1

Hi, it would be great to add a random sorting option for collections, for example, for displaying testimonials across the site.


#2

Yes, please! And every page reload randomizes again!


#3

Haha how would this happen?


#4

@thesergie
Have a parent class for the dynamic list, then the same class for each dynamic list item, and the js used on this page:
http://jsfiddle.net/BwJHj/1/


#5

OOh I feel you now... every page load would randomize the list. For some reason i thought you meant that clicking on an item would choose a random page for you. :scream:


#6

That would be wild! I'm gonna try and use this js real quick to see if I can get it working on a dynamic list :smiley:


#7

thanks @Waldo! that would be super cool!


#8

I need this so much, my client want a randomized order of brands and i dont know how do it. =/


#9

Yes, this is absolutely a "must have", and quickly !!! A lot of people needs random sorting of collections...


#10

Mmmm....random sorting. We want it :smile:


#11

Yes, random sorting!!


#12

Hey @discovoador @buntestrahlen @tmfukushima @mietlicki @perkristian & @davidvm you can achieve this by adding in the following script (replace the “listitemclassname” with the class name which you give your list items):

    <script> var cards = $(".listitemclassname");
for(var i = 0; i < cards.length; i++){
    var target = Math.floor(Math.random() * cards.length -1) + 1;
    var target2 = Math.floor(Math.random() * cards.length -1) +1;
    cards.eq(target).before(cards.eq(target2));
} </script>

Here’s an example:

Here’s the Webflow Read-Only link: https://preview.webflow.com/preview/flow-in?preview=99d20c3007c32ab09ef1da4455a8de8c

Feel free to ask any questions. :slight_smile: Have fun!


Ability to refresh random sort on page refresh
Random Sorting / Code Help
If I filter a collection, does Random sorting still supposed to work?
#13

i will try that tomorrow. trank you!


#14

Yep, all I needed, thanks @Waldo!


#15

Thanks Waldo, i'll try today. If works, will safe me a lot of time (until now, i made a sort list manualy every week =/)


#16

Currently our caching for CMS sites gets cleared every 12hrs (twice in one day). So that means if we have sort set to random it will be randomized every 12 hours. Would that work?


#17

Great @thesergie, that would absolutely do the trick for me. :smile:


#18

@perkristian @tmfukushima @discovoador @buntestrahlen @mietlicki @davidvm your wishes have come true:


#19

@perkristian @tmfukushima @discovoador @buntestrahlen @davidvm

Thanks for your patience. This feature is now live! Try it out :smile:


#20

Great stuff @PixelGeek & @Waldo! :smile:
Works like a charm :beers: