Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

Many Many Relationship -> get just one category


Reply

2 Posts   949 Views

Avatar
StarForce

8 November 2010 at 4:51am Community Member, 11 Posts

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

Avatar
baba-papa

13 November 2010 at 8:52am Community Member, 279 Posts

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

$category->news()