Ok So I have these two models:
class NewsPage extends Page {
static $has_many = array ('News' => 'News');
}
class News extends DataObject{
static $has_one = array('Parent'=>'NewsPage');
}
(I am omitting details, but there is nothing out of the ordinary, simply $db, $summary_fields, and getCMSFields()).
In my template, if I <% control News %>, I get 4 news. But there are 10.
If I add this function in my NewsPage:
function News(){
return DataObject::get('News','ParentID="'.$this->ID.'"');
}
It works. This has me quite baffled; isn't the automatic $NewsPage->News function supposed to be doing just that?
Note that if I call the function getNews() I get only 4 news again.
Also, I checked in the database and all News objects have a correct ParentID set.