7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » How to remove duplicated entries from displaying?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 887 Views |
-
How to remove duplicated entries from displaying?

6 January 2010 at 1:27am
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!
-
Re: How to remove duplicated entries from displaying?

6 January 2010 at 2:20am
function GetNewsByLogos() {
if($set = DataObject::get("NewsPage", "ParentID = 111 AND `NewsPage`.LogoID != '' "))
return $set->removeDuplicates();
return false;
} -
Re: How to remove duplicated entries from displaying?

6 January 2010 at 3:35am Last edited: 8 January 2010 12:00am
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=2In 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
Mindaugas
| 887 Views | ||
|
Page:
1
|
Go to Top |

