Bruno17 / MIGX

MIGX for revo 2.2 and above
83 stars 78 forks source link

MigxLoopCollection Random #312

Open kelly8116 opened 6 years ago

kelly8116 commented 6 years ago

Is there any way to randomize migxLoopCollection similar to getImageList?

I've tried multiple combinations:

                    [[!migxLoopCollection? 

                        &packageName=`testimonials`
                        &classname=`Testimonial`

                        &tpl=`testimonialTpl`
                        &where=`{"published" : "1"}` 
                        &randomize=`1`
                        &offset=`0`
                        &limit=`1`

                    ]]
                    [[!migxLoopCollection? 

                        &packageName=`testimonials`
                        &classname=`Testimonial`

                        &tpl=`testimonialTpl`
                        &where=`{"published" : "1"}` 
                        &limit=`1`
                        &sortby=`RAND()`

                    ]]
                    [[!migxLoopCollection? 

                        &packageName=`testimonials`
                        &classname=`Testimonial`

                        &tpl=`testimonialTpl`
                        &where=`{"published" : "1"}`
                        &limit=`1`
                        &sortConfig=`[{"sortby":"RAND()"}]`

                    ]]

Additionally, nothing seems to change the sort order.

dimitrihilverda commented 3 years ago

This should work: &sortConfig=[{"sortby":"RAND()","sortdir":"ASC"}]

That way the chosen field is randomised, giving you a differed order, the more columns/fields you have the more random it looks.