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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

How to remove duplicated entries from displaying?


3 Posts   1161 Views


6 January 2010 at 1:27am Community Member, 51 Posts

Hi there,

I have many-many DOM where Logos are related to NewsPages. I would like to get a NewsPages where LogoID is unique (would like to show only one newspage where is the same LogoID). How could I use array_unique with this dataobject set?:

function GetNewsByLogos() {
    $doSet = DataObject::get(
      $callerClass = "NewsPage",
      $filter = "`SiteTree`.ParentID = 111 AND `NewsPage`.LogoID != '' ",
      $sort = "",
      $join = "",
      $limit = ""
    return $doSet ? $doSet : false;

Thanks for any help!


6 January 2010 at 2:20am 4085 Posts

function GetNewsByLogos() {
if($set = DataObject::get("NewsPage", "ParentID = 111 AND `NewsPage`.LogoID != '' "))
return $set->removeDuplicates();
return false;


6 January 2010 at 3:35am (Last edited: 8 January 2010 12:00am), Community Member, 51 Posts

To: UncleCheese

I tried your code, but it's bringing me no entries after "removeDuplicates".

Before "removeDuplicates" I successfully got 3 news entries:

id1 entry1 logoID=1
id2 entry2 logoID=1
id3 entry3 logoID=2

In example above entry2 has the same logo (logoID=1) and needed to be removed from the displaying on the page. Any ideas how to get this?

I appreciate your help.

Best regards