Here is my situation:
I have one class StadtBild extends Dataobject, which is in an has_one / has_many with Stadt (ie. each Stadt has many Stadtbilder)
I would like to put a summary of these on the front page, which is not in the same hierarchy as Stadt. I also have many instances of Stadt.
on the front page, i have the following function in the controller:
function summarize(){
$pages = DataObject::get('Stadt', "", 'LastEdited DESC', null, 5);
foreach($pages as $page){
$page->StadtBilder = DataObject::get("StadtBild", "StadtID = $page->ID", "Name DESC", "", 5);
}
return $pages;
}
Basically, the DataObject subset $page->StadtBilder refuses to be overwritten. I've tried the obvious methods (add, remove) listed here(http://api.silverstripe.com/default/DataObjectSet.html) as well as a few other ways of doing it. For reference, the template files looks like this:
<% control summarize %>
<div class="summaryitem"><a href="$Link">$Title</a>
<ul class="summarylist">
<% control StadtBilder %>
<li title="$Name"><a href="$Link" target="_blank">$Attachment</a><br /> $Description
<% end_control %>
</ul>
</div>
<% end_control %>
The result of the current code is that the StadtBilder are not reduced to the first 5.
I've had really bad luck getting responses here, if my questions isn't helpful, could someone please help me to ask a more answerable question? I'm keen to learn, even after day 2 of this problem.
Thanks in advance.