Hi
I'm trying to add the latest 5 images to the homepage of a site, I don't really know how to do it. Is this feature already in the image gallery module some where? if not any ideas how to get this to work?
Thanks in advance
FireMe
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
Hi
I'm trying to add the latest 5 images to the homepage of a site, I don't really know how to do it. Is this feature already in the image gallery module some where? if not any ideas how to get this to work?
Thanks in advance
FireMe
function LatestImages()
{
return DataObject::get("ImageGalleryItem", null, "Created DESC", null, 5);
}
thanks for the fast reply unclecheese, but I have one more question, I think :-)
firstly i put this code in my template
<% control LatestImages %>
<li style="height:{$Top.ThumbnailSize}px;width:{$Top.ThumbnailSize}px;">
<a id="ViewLink-$ID" rel="$RelAttr" class="$ClassAttr" title="$Caption" href="$ViewLink"><img src="$ThumbnailURL" alt="$Title"/></a>
</li>
<% end_control %>
but it did not seem to display the image, just a link that does not work. So I tried this code
<% control LatestImages %>
$Thumbnail
<% end_control %>
Which worked, but I could not figure out how to get a link to it that worked, also how would I control the the thumbnail size.
thanks in advance
FireMe!
all I want to do is have it use the lightwindow, any one know how to?
Just include the required javascript and use the markup that it requires. The Lightwindow documentation should explain how to do that.
I found this post while searching on how to display ImageDataObjectManager items on the home page. I got it working using the code examples in this post.
I used UncleCheese's code snippet:
function LatestImages()
{
return DataObject::get("ImageDataObjectManagerItem", null, "Created ASC", null, 2);
}
on mysite/code/HomePage.php
and added this to themes/blackcandy/templates/layout/HomePage.ss
<% control LatestImages %>
<img src="$Attachment.URL" alt="$field1" title="$field1 - $field2" /><br />
$field1<br />$field2<br />$field3
<% end_control %>
Is this the best way to do this using an ImageDataObjectManager item? What are the NULL fields in the array for?
Yup, that's the best way to do it. I'm going to be adding in a LatestImages function to the image_gallery core so this will be a lot easier. I'll also be adding a publicly accessible method includeUI() so you can get your lightbox UI anywhere on your site.
The null values are for the filter and join arguments.
Hi Uncle Cheese
Will this function enable the latest images from a single albumto be displayed on another page (e.g homepage?)
I was working with a Image Gallery Widget
http://www.silverstripe.org/dataobjectmanager-module-forum/show/265603#post265603
I can get latest images shown - but from all albums
I am trying to make a widget that you can configure to show a featured albums images- I am have trouble limiting the number of images shown (referenced as Gallery Items)
Code I am using in widget
function LatestGallery() {
$album = DataObject::get_one("ImageGalleryAlbum", "FeaturedAlbum = 1");
//Debug::show($album);
return $album;
}
Template code
<% control LatestGallery %>
<div id="latestEvents">
<div class="title">
<h2>Latest Events</h2>
<h3><a class="$LinkingMode" href="$Link" title="$AlbumName">$AlbumName</a></h3>
</div>
<ul class="latestPictures">
<% control GalleryItems %>
<li style="height:{$Top.ThumbnailSize}px;width:{$Top.ThumbnailSize}px;">
<a id="ViewLink-$ID" rel="$RelAttr" class="$ClassAttr" title="$Caption" href="$ViewLink">$Image.SetWidth(100)</a>
</li>
<% end_control %>
</ul>
</div>
<% end_control %>