Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Is it possible to control specific images for "Number of images per page"?


14 Posts   1459 Views


23 December 2009 at 10:42pm Community Member, 168 Posts

I wasn't exactly sure where to place it as I get errors or no result:


class MyImageGalleryPage extends ImageGalleryPage {
protected function Items($limit = null) {
if($limit === null && $this->MediaPerPage ) {
if( !isset($_REQUEST['start']) || ! is_numeric( $_REQUEST['start'] ) )
$_REQUEST['start'] = 0;

$limit = $_REQUEST['start'] . "," . $this->MediaPerPage;

$filter = ($current_album = $this->CurrentAlbum()) ? "AlbumID = {$current_album->ID} AND" : "";
/* new */
$filter .= " Set = '1' AND";
/* *** */
$files = DataObject::get(
"$filter ImageGalleryPageID = {$this->ID}",
return $files;

class MyImageGalleryPage_Controller extends ImageGalleryPage_Controller {


Which shows this error:

[User Error] Couldn't run query: SELECT `ImageGalleryItem`.*, `MyImageGalleryItem`.*, `ImageGalleryItem`.ID, if(`ImageGalleryItem`.ClassName,`ImageGalleryItem`.ClassName,'ImageGalleryItem') AS RecordClassName FROM `ImageGalleryItem` LEFT JOIN `MyImageGalleryItem` ON `MyImageGalleryItem`.ID = `ImageGalleryItem`.ID WHERE (AlbumID = 1 AND Set = '1' AND ImageGalleryPageID = 6) ORDER BY SortOrder ASC LIMIT 0,9 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Set = '1' AND ImageGalleryPageID = 6) ORDER BY SortOrder ASC LIMIT 0,9' at line 1


24 December 2009 at 3:39am 4085 Posts

Haha... That's funny. "Set" is a reserved keyword in MySQL. So change that to `Set`.


24 December 2009 at 6:37am Community Member, 168 Posts

OK well that has helped, but I think this is kinda of working in reverse.. My gallery items which are checked as 'Set' are the ones I wish to hide the thumbs of, then keep the rest and have everything display in the lightbox via next, next etc.

Using that code means it filters the ones which are not 'Set' completely and I am left with empty pages of the hidden thumbs. If I change:

$filter .= " `Set` = '1' AND";


$filter .= " `Set` = '0' AND";

It filters the correct ones the 'Set' items but the others are no longer part of the gallery at all, not in the code, and do not display in the lightbox...


24 December 2009 at 6:43am 4085 Posts

I think a better criterion to use is `Set` != '1', because by saying `Set` = '0', you're assuming set can only be 1 or 0, and my guess is there are some null values in there for whatever reason.


24 December 2009 at 6:48am Community Member, 168 Posts

OK that is still showing the correct thumbs in the gallery, but the Set thumbs are still completely removed from the source and therefor the lightbox too..


24 December 2009 at 7:27am 4085 Posts

Oh, so the Set images should be in the recordset after all?

I'm not sure if what you're trying to do is even possible. Your visual page limit and your query record limit are inconsistent. I don't know how you could reconcile that without completely changing the way pagination is handled.

That's certainly a tough one. If you get into a jam you can reach me through my website to commission the work. That's about all I can offer at this point.