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.

Archive /

Our old forums are still available as a read-only archive.

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

Displaying latest gallery images on the homepage


2 Posts   1022 Views


Community Member, 104 Posts

6 October 2008 at 9:14pm


On my homepage, I have the 3 newest articles from my "news" and "blog" pages, but would also like to show the 3 newest pages from my gallery.

class NewHomePage_Controller extends Page_Controller {
   function LatestNews() {
      $news = DataObject::get_one("ArticleHolder");
      return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", 3) : false;

However the method used above (taken from the tutorials on the Silverstripe website) simply doesn't work for the GalleryPages.

Any suggestions

Thanks (as always)


Community Member, 63 Posts

6 October 2008 at 9:41pm

Hi I have started working on this : the GalleryFolder page type is an example of gallery images being displayed on a parent page. The only problem with this is that the ChildGalleries function gives a hard job to the server when images have not been resized yet by sub galleries. Complete package with template is available on my [url=]jquery gallery module implementation[/url]

* Defines the GalleryFolder page type
class GalleryFolder extends Page {
static $db = array(
static $has_one = array(

// static $allowed_children = array('GalleryPage', '');

class GalleryFolder_Controller extends Page_Controller {

function ChildGalleries( ) {
$ChildGalleries = DataObject::get("GalleryPage", "ParentID = " . $this->ID);
//? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false
return ($ChildGalleries) ;
function init() {


<div id="ImageGalleryFolder"><ul>
<% control ChildGalleries %>
   <li><a href="$Link" alt="$Parent.Title">
<% if CurrentGalleryItems %>

         <% control GalleryItems(1) %>
   <img src="$ThumbnailURL" alt="$Parent.Title" title="$Parent.Title" />
         <% end_control %>

<% end_if %>
</a> </li>
<% end_control %>