21308 Posts in 5737 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1018 Views |
-
DataObject::Get no success

25 February 2010 at 1:28am
Hi!
In my Tree I have News Section (Type:News) with some Childs (Type:ArticlePage)...
What I want to do is listing some news in the News-Page.
Is the following function within the controller section of the news.php the right approach?
First get the parent ID and then the child infos?function LatestNews($num=3) {
$news = DataObject::get_one("News");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;When I control the function the result (e.g. $Title) is empty...
Thanks,
tom -
Re: DataObject::Get no success

25 February 2010 at 1:43am
Hi there
That looks fine to me. You could even ditch the part where you get the parent, since you're already in the parent?
function LatestNews($num = 3){
return DataObject::get('ArticlePage', 'ParentID = ' . $this->ID, 'Date DESC', '', $num);
}How does your template code look like?
-
Re: DataObject::Get no success

25 February 2010 at 1:58am
Hi,
thanks!
Template code is quite easy:
<% control LatestNews %>
$Title
$Content
<% end_control %>What would be interesting is the question how
one can add additional filter criteria like:Show only childs from number 3 to e.g. number 6
or
what can I use to access just one child directly...(show only child number 5)thanks for your ideas...
tom
| 1018 Views | ||
|
Page:
1
|
Go to Top |


