Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Displaying latest gallery images on the homepage

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

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

Page: 1
Go to End
Author Topic: 968 Views
  • bones
    Community Member
    104 Posts

    Displaying latest gallery images on the homepage Link to this post


    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)

  • erwanpia
    Community Member
    63 Posts

    Re: Displaying latest gallery images on the homepage Link to this post

    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 jquery gallery module implementation

    * 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 %>

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.