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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Limit Control??**SOLVED**


4 Posts   935 Views


23 April 2013 at 1:29am (Last edited: 23 April 2013 4:19am), Community Member, 123 Posts

Hi All,

I have a gallery which I am using DataObject Manager to add multiple images and it all works fine.

However I want to display the first 3 images of the gallery on another page.

I've searched for a solution and tried figuring it out myself but have had no success.

I can get the images to appear on the other page but it shows all of them instead of just 3.

This is my code that I have tried

<% if GalleryImages %>
   <% control GalleryImages(3) %>
<div class="listing_pic">
         <a href="$Link"><img src="$MyGalleryImage.GroupThumb.URL" alt="<% sprintf(_t("IMAGE","%s image"),$Title) %>" /></a>
<% end_control %>
<% end_if %>

I also have tried

public function GalleryImages($Limit = 3){

return DataObject::get("GalleryImage", "ParentID = $this->ID", Null, Null, $Limit);


Any help would be appreciated, Thanks

** EDIT - I am using ss 2.4


23 April 2013 at 7:40pm Community Member, 123 Posts

Nobody has any ideas on this?

I thought it would be straightforward enough to do but just haven't figured out what I'm doing wrong :(


30 April 2013 at 7:28am Community Member, 34 Posts


Maybe try this

function NewestGalleryImages($num=3) {
$GalleryImages = DataObject::get_one("GalleryImage");
      return ($GalleryImages) ? DataObject::get("GalleryImage", "", "ParentID = $this->ID", "", $num) : false;

let me know



1 May 2013 at 9:44pm Community Member, 123 Posts

Thank you Darren,
I had some help from IOTI here [url][/url]

And this got it working in the end

public function GImages($limit = 3){
$filter = 'BelongToProductID =' . $this->ID; //filter
if($images = DataObject::get('GalleryImage', $filter, $sort='', $join='', $limit="0,$limit")){
return $images;