Remove duplicate results

By James KanjoJames Kanjo

Description

Sometimes, if you are using the ListPages module for data presentation, you may list duplicate results. In such cases, you can use this special add-on to remove all duplicated instances, and place them in a list.

Code

Create an inc:iframe-append page, and on it, copy and paste the following code:

{$no-results}
[[embed]]
<iframe src="about:blank" style="display: none; [!----]"></iframe>[[/embed]]

You would then use a ListPages module to compile the list that may have duplicate results:

[[module ListPages perPage="250" limit="250" separate="false" appendLine="[[include inc:iframe-append |no-results=Sorry! There appears to be no results matching your specified criteria...]]"]]
[[embed]]<iframe frameborder="0" scrolling="auto" style="width: 100%; height: 300px;" src="http://snippets.wdfiles.com/local--code/code:remove-duplicate-results[!----]#ITEM[!--
[[/module]]

If you would like to use your own custom CSS for this module, just prepend ##CSS-URL to the [!----] code, like so:

[[module ListPages perPage="250" limit="250" separate="false" appendLine="[[include inc:iframe-append |no-results=Sorry! There appears to be no results matching your specified criteria...]]"]]
[[embed]]<iframe frameborder="0" scrolling="auto" style="width: 100%; height: 300px;" src="http://snippets.wdfiles.com/local--code/code:remove-duplicate-results##CSS-URL[!----]#ITEM[!--
[[/module]]

The CSS class used to control the items in the list is .unique-item

In action

This code would be useful if you want to list the most active users over the past 24 hours:

**Currently Active Users:**
[[module ListPages category="*" order="updated_at desc" date="last 1 day" perPage="250" limit="250" separate="false" appendLine="[[include inc:iframe-append |no-results=There appears to be no active users over the past 24 hours...]]"]]
[[embed]]<iframe frameborder="0" scrolling="auto" style="width: 100%; height: 125px;" src="http://snippets.wdfiles.com/local--code/code:remove-duplicate-results[!----]#%%created_by%%[!--
[[/module]]

Currently Active Users:

Rate this solution

If you think this solution is useful — rate it up! Or dump it otherwise.

rating: +5+x
leigerleiger 1256608042|%e %b %Y, %H:%M %Z|agohover

Edit: nevermind


— Shane | Blog | CycloDS Revolution | Compatibility List | Get your free Wiki! | XBL: leiger40
100% Wikidot. 100% Awesome.

last edited on 1256608189|%e %b %Y, %H:%M %Z|agohover by leiger + show more
unfold by leigerleiger, 1256608042|%e %b %Y, %H:%M %Z|agohover
gerdamigerdami 1256628138|%e %b %Y, %H:%M %Z|agohover

Well done, James.
Now it would be great if you could count the contributions per user and append (nn) to username, with a new class .count-item, for {display:none;} if not wanted.

unfold by gerdamigerdami, 1256628138|%e %b %Y, %H:%M %Z|agohover
Add a new comment
page_revision: 8, last_edited: 1256608778|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License