CMS MADE SIMPLE FORGE

Image rotator

 

[#4464] Fix Image Sort Issue

avatar
Created By: Phil Scoltock (mantapro)
Date Submitted: 2009-12-17 13:37

Assigned To: Alberto Benati (alby)
Resolution: None
State: Open
Summary:
Fix Image Sort Issue
Detailed Description:
I have found that the Natural Sort feature if the random parameter is set to
false does't quite work as I expected.

The natural sort is done to the array of image file names, and then a javascript
array is created using both the values of the PHP array and the value of the
keys from the PHP array. When the javascript cycles through the images rather
than reading through them from the first occurance defined to last, it instead
reads them using the array key. In effect this returns the sequence of images
back to original pre natural sort order. To fix this is simple, just replace
this:

			if($random) shuffle($fileList);
			else natsort($fileList);
with this :
			if($random) shuffle($fileList);
			else natsort($fileList);
                        $fileList = array_values($fileList);

(ps. I know that there is a different image rotator listed in the tag download
section of CMSmadesimple now, but it lacks many features of your more useful
version)

Thanks Phil

History