3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 241 Views |
-
[SOLVED] Automatic scaffolding not returning the correct number of children

21 October 2011 at 2:50am Last edited: 21 October 2011 2:52am
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.
-
Re: [SOLVED] Automatic scaffolding not returning the correct number of children

21 October 2011 at 6:50am
If you set the site in dev mode, and then do a ?showqueries=1 you can at least take a look at the query and see wat it's doing...
-
Re: [SOLVED] Automatic scaffolding not returning the correct number of children

21 October 2011 at 12:44pm
Ok got it...Very stupid of me.
There is this customized Page class that I recycle across sites, and it has a News($number=4) function, usually for displaying stuff in sidebars.
| 241 Views | ||
|
Page:
1
|
Go to Top |

