7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Is it possible to control specific images for "Number of images per page"?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 1138 Views |
-
Re: Is it possible to control specific images for "Number of images per page"?

23 December 2009 at 10:42pm
I wasn't exactly sure where to place it as I get errors or no result:
MyImageGalleryPage.php
<?php
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(
$this->getItemClass(),
"$filter ImageGalleryPageID = {$this->ID}",
null,
"",
$limit
);
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
-
Re: Is it possible to control specific images for "Number of images per page"?

24 December 2009 at 3:39am
Haha... That's funny. "Set" is a reserved keyword in MySQL. So change that to `Set`.
-
Re: Is it possible to control specific images for "Number of images per page"?

24 December 2009 at 6:37am
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";
to
$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...
-
Re: Is it possible to control specific images for "Number of images per page"?

24 December 2009 at 6:43am
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.
-
Re: Is it possible to control specific images for "Number of images per page"?

24 December 2009 at 6:48am
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..
-
Re: Is it possible to control specific images for "Number of images per page"?

24 December 2009 at 7:27am
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.
| 1138 Views | ||
| Go to Top |

