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   969 Views

Avatar
StarForce

Community Member, 11 Posts

8 November 2010 at 4:51am

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

Community Member, 279 Posts

13 November 2010 at 8:52am

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

$category->news()