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