They are 777 in my set-up....
@Sharkbait: it shows the same for each image for me also.. When you rearrange the images, the script posts a lot of sort[] names back to the module. Those names each have a value of the image in that position, so the post order is how the sort should be done...
However, that’s not what this script does:
elseif (isset($_POST['cmdsort'])) // Update image sort order
{
foreach ($_POST['sort'] as $key => $filename)
{
$modx->db->update("sortorder='" . $key . "'", $modx->getFullTableName($this->galleriesTable), "filename='" . urldecode($filename) . "' AND content_id='" . $content_id . "'");
}
}
It checks for the cmdsort post (which is also sent with the batch of sort[] values), and then starts looping through the post values.
Then it sets the sortorder column in the database to $key, which is 0? Or perhaps even ’’?
I’ll see if I can come up with a fix on my test server....
Managed to get a simple fix for the sortorder not updating:
elseif (isset($_POST['cmdsort'])) // Update image sort order
{
$sortnum = 0; //## 16/6/2010 Mark Hamstra
foreach ($_POST['sort'] as $key => $filename)
{
$sortnum++; //## 16/6/2010 Mark Hamstra !vvvvv!
$modx->db->update("sortorder='" . $sortnum . "'", $modx->getFullTableName($this->galleriesTable), "filename='" . urldecode($filename) . "' AND content_id='" . $content_id . "'");
}
}
Line 279+ from the management.class.inc.php file, found in /assets/modules/evogallery/classes. My changes have been marked (!vvvvv! refers to the $sortnum in the query which I changed from $key).
The above fix makes sure that when you hit "Save Order" it will actually save it. To also fix the sortorder when uploading new images, you’ll need another one too:
// Find the last order position
$rs = $modx->db->select('sortorder', $modx->getFullTableName('portfolio_galleries'), '', 'sortorder DESC', '1');
if ($modx->db->getRecordCount($rs) > 0)
$pos = $modx->db->getValue($rs) + 1; // ## 16/6/2010 Mark Hamstra (+1)
else
$pos = 1; // ## 16/6/2010 Mark Hamstra (1)
Line 58+ of the upload.php file, found in /assets/modules/evogallery
By adding "1" to the highest found value, you increase it, otherwise it would be the same.
Also for the $pos = 1;, you need it to be higher then 0, or the if call above it will never fire off, increasing the sortorder for the next image.
When testing this, I found that it was still not using the sortorder column, but that it was sorting on the ID of the image. To "fix" this, specify "sortorder" in the sortBy parameter or change the default setting in the snippet (in the manager).
These fixes applied to a clients site fixed it there also.