Remove Duplications

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

Use the ListPages module to compile the list that may have duplicate results:

[[module ListPages perPage="250" limit="250" separate="false" appendLine="[[include :snippets:code:_rdr |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 :snippets:code:_rdr |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 :snippets:code:_rdr |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:

There appears to be no active users over the past 24 hours…


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by James Kanjo


Rate this solution

If you think this solution is useful — rate it up!

rating: +5+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License