7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Limiting Results of Control
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 949 Views |
-
Limiting Results of Control

24 February 2010 at 4:19pm Last edited: 24 February 2010 4:20pm
I have the following code that displays all the posters belonging to the Movie Page. I'm using the same code on the Homepage as I'm using a specific function to pull in the Movie pages on the homepage. On the homepage I want to limit the number of posters to 4. I can't seem to do this any help?
<ul class="movieList">
<% control MoviePages %>
<li>
<h2><a href="$Link">$Title<% if MovieVersion %> <span>($MovieVersion)</span><% end_if %></a></h2>
<% if ReleaseDate %><p><strong>Release Date:</strong> $ReleaseDate.Nice</p><% end_if %>
<h3>Sypnosis</h3>
$Content
<h3>Posters</h3>
<% if Posters %>
<ul class="posters clear">
<% control Posters(4) %>
<li>
<a href="<% control PosterImage %>$URL<% end_control %>" title="$Pos/$TotalItems - $PosterName" rel="$MoviePage.Title"><% control PosterImage %><img src="<% control CroppedImage(125,188) %>$URL<% end_control %>" alt="$Title Poster Thumbnail" width="<% control CroppedImage(125,188) %>$Width<% end_control %>" height="<% control CroppedImage(125,188) %>$Height<% end_control %>" /><% end_control %><span></span></a>
</li>
<% end_control %>
</ul>
<% else %>
<h5>No Posters Yet</h5>
<p>Do you have a poster for this movie? Please <a href="contact">send it to us</a> so we can add it to the site.</p>
<% end_if %>
</li>
<% end_control %>
</ul> -
Re: Limiting Results of Control

24 February 2010 at 4:39pm
You just need to write a custom getter..
function HomePosters()
{
return $this->Posters(null, null, null, 4);
} -
Re: Limiting Results of Control

24 February 2010 at 4:53pm
I tried doing this:
Homepage.phpfunction MoviePosters() {
$doSet = DataObject::get(
$callerClass = "Poster",
$filter = "`MoviePageID` = '".$this->ID."'",
$sort = "Sort DESC",
$join = "",
$limit = "0,4"
);
return $doSet ? $doSet : false;
}
Homepage.ss<% control MoviePosters %>
test
<% end_control %>It doesn't produce anything.
-
Re: Limiting Results of Control

24 February 2010 at 5:42pm
$filter = "`MoviePageID` = '".$this->ID."'",
MoviePages are associated with your homepage? Seems odd.
| 949 Views | ||
|
Page:
1
|
Go to Top |

