Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » News on home 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: 156 Views
  • tomjohn
    Avatar
    Community Member
    6 Posts

    News on home page Link to this post

    I have site with menu:

    Home
    Category1
    ---Subcategory
    ---Subcategory
    ---Subcategory
    Category2
    ---Subcategory
    ---Subcategory
    ---Subcategory
    Category3
    ---Subcategory
    ---Subcategory
    ---Subcategory
    Category4
    ---Subcategory
    ---Subcategory
    ---Subcategory

    Subcategories have news, but all news are visible only in parent category. Subcategories are hidden on page. I use in CategoryPage.php code :

    $pageIDs = $this->getDescendantIDList();
           $doSet = DataObject::get(
           $callerClass = "News",
           $filter = "`CategoryPageID` IN (" . implode(",", $pageIDs) . ")" . $filterStatement,
           $sort = "Created DESC",
    //$sort = "RAND()",
           $join = ""

           );      

          
    It list all news from subcategories on category page.

    Now I want put on home page 4 modules with a few news from each category. How can I change this code to work?

    Code:
    $doSet = DataObject::get(
           $callerClass = "News",
           $filter = "`CategoryPageID` = '7'" . $filterStatement,

           $sort = "ID DESC",
           $join = ""
           );   
    give me news from only one subcategory.
    sSomeone can help me?   

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: News on home page Link to this post

    give me news from only one subcategory.

    If news are a child page of the subcategory then an additional filter like ParentID = '4' will get you just news under '4'

    156 Views
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.