17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 864 Views |
-
Displaying latest gallery images on the homepage

6 October 2008 at 9:14pm
Hi,
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)
-
Re: Displaying latest gallery images on the homepage

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 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() {
parent::init();
Requirements::css("gallery/css/Gallery.css");
}
}template
<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" />
<br>$Parent.MenuTitle
<% end_control %><% end_if %>
</a> </li>
<% end_control %>
</ul></div>
| 864 Views | ||
|
Page:
1
|
Go to Top |

