Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Many Many Relationship -> get just one category

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 926 Views
  • StarForce
    Avatar
    Community Member
    11 Posts

    Many Many Relationship -> get just one category Link to this post

    Hi

    i´ve created a many-many relationship (news <-> category)

    when using this code, i get all news:

    $news = DataObject::get_one("NewsHolder");
    return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Datum DESC", "", $num) : false;,

    what do i have to do, to just get all news for one category?

    Thanks

    StarForce

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Many Many Relationship -> get just one category Link to this post

    if the relation on category is called "news" you can simply call the related objects like:

    $category->news()

    926 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.