7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [SOLVED] ImageGallery - Previous/Next Album
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 816 Views |
-
[SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 11:12am Last edited: 22 May 2009 11:47am
Hi all,
I have UncleCheese's ImageGallery module installed on 2.3.1 and everything seems to be fine. I have added three albums: First Album, Second Album and Last Album.
The oddity I am noticing is where it display's Previous and Next album navigation.
When First Album is open:
Previous Album = blank (correct)
Next Album = Last Album (incorrect)When Second Album is open:
Previous Album = First Album (correct)
Next Album = Last Album (correct)When Last Album is open:
Previous Album = First Album (incorrect)
Next Album = blank (correct)Known bug? Any ideas?
Cheers
Aaron -
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 11:17am
I'm aware of it. The problem is in assigning a default sort value to a newly created Album. They probably all have null values or 0 right now so it's not able to order them correctly. You can do a quick fix by sorting the albums once in the DataObjectManager. Even if you don't re-order them, just pick one up and put it down to call the script.
I'll put this in the bug reports thread.
-
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 11:28am
Cheers mate.
I deleted the albums and added them again (in order) to see what happened in the table sortorder. As follows:
First Album = 0
Second Album = 2
Last Album = 3I then dragged First Album under Second Album
First Album = 1
Second Album = 0
Last Album = 2Then dragged First Album to the first position and:
First Album = 0
Second Album = 1
Last Album = 2Yet, First Album behaviour is the same. Second and now Last Album are working as expected.
Aaron
-
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 11:43am
Hi UC,
I have fixed the bug on my installation, and it was to do with the Sort order in the adjacentAlbum method of ImageGalleryPage.php
Orig code:
protected function adjacentAlbum($dir)
{
$t = $dir == "next" ? ">" : "<";
return DataObject::get_one(
"ImageGalleryAlbum",
"ImageGalleryPageID = {$this->ID} AND SortOrder $t {$this->CurrentAlbum()->SortOrder}",
false,
"SortOrder DESC"
);
}My fix: See extra $sort var, and the insertion of that var in the Sort param for the query.
protected function adjacentAlbum($dir)
{
$t = $dir == "next" ? ">" : "<";
$sort = $dir == "next" ? "ASC" : "DESC";
return DataObject::get_one(
"ImageGalleryAlbum",
"ImageGalleryPageID = {$this->ID} AND SortOrder $t {$this->CurrentAlbum()->SortOrder}",
false,
"SortOrder $sort"
);
}It appears that simple Less Than, Greater Than where statements are dependant on the order of table contents, depending on which end of the Album Order the current request is coming from.
Cheers
Aaron -
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 11:46am
Confirm adding forth album. All Prev/Next links are displaying as expected.
Cheers
Aaron -
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 11:56am
Confirm deleting all albums and adding the test 3 from scratch. All Prev/Next links displaying as expected.
Cheers
Aaron -
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 1:40pm
Gah... what a bonehead mistake. Thanks for figuring it out. I'll check in the update.
-
Re: [SOLVED] ImageGallery - Previous/Next Album

22 May 2009 at 2:01pm
Given the coolness and intricacy of the module, a few little logic hiccups are to be expected.
Kudos on this work mate.
Cheers
Aaron
| 816 Views | ||
|
Page:
1
|
Go to Top |

