Jump to:

23545 Posts in 19310 Topics by 2888 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, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1147 Views
  • Amir Mostofi
    Community Member
    59 Posts

    List news pages under a newsholder page Link to this post

    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?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.