17691 Posts in 4607 Topics by 2180 members
General Questions
SilverStripe Forums » General Questions » List news pages under a newsholder page
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 813 Views |
-
List news pages under a newsholder page

25 August 2009 at 5:09pm Last edited: 25 August 2009 5:12pm
I have defined NewsHolder and NewsPage classes as instructed in the SilverStripe Tuts. Now, I have page 1 of type NewsHolder and subpage 11, subpage 12, ... of type NewsPage under it. I also have page 2 of type NewsHolder and subpage 21, subpage 22, ... of type NewsPage under that. In the sitemap, Page 1 appears above Page 2.
Now, I have defined the following function in NewsHolder.php
function NewsArchive() {
$news = DataObject::get_one("NewsHolder");
return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Date DESC") : false;
}In my templates, this function correctly lists the news items under Page 1, but on Page 2, the news list returned is that of Page 1. The function only selects the first instance of NewsHolder in the sitemap. How can I use class NewsHolder for multiple pages and correctly generate the chronological list of NewsPage pages under each NewsHolder page?
| 813 Views | ||
|
Page:
1
|
Go to Top |
