Help:DPL Examples/Test distinct

From Terraria Wiki
Jump to navigation Jump to search

distinct test:

Backlinks (52)

Code

{{#dpl:
|namespace=Help
|linksto={{FULLPAGENAME}}{{!}}{{FULLPAGENAME}}s{{!}}{{FULLPAGENAME}}es{{!}}{{FULLPAGENAME}}ies{{!}}{{FULLPAGENAME}}ing{{!}}{{FULLPAGENAME}}ed{{#if:{{{2}}}|{{!}}{{{2}}}{{!}}{{{2}}}s|}}{{#if:{{{3|}}}|{{!}}{{{3}}}{{!}}{{{3}}}s|}}
|resultsheader=<h2>Backlinks (%PAGES%)</h2>
}}

Description

The reason why this query shows several entries for distinct test is that the uniqueness requirement refers to the combination of referring page and referred page. Note that a referring page might contain several references to the same page (which you wouldn´t want to see in the listing). DPL offers a variable named %PAGESEL% which shows the referring page. If we add that variable to the example we see why there are several occurencies of distinct test in the output:

Backlinks (52)

Code

{{#dpl:
|namespace=Help
|linksto={{PAGENAME}}{{!}}{{PAGENAME}}s{{!}}{{PAGENAME}}es{{!}}{{PAGENAME}}ies{{!}}{{PAGENAME}}ing{{!}}{{PAGENAME}}ed{{#if:{{{2}}}|{{!}}{{{2}}}{{!}}{{{2}}}s|}}{{#if:{{{3|}}}|{{!}}{{{3}}}{{!}}{{{3}}}s|}}
|resultsheader=<h2>Backlinks (%PAGES%)</h2>
|format=,\n*[[%PAGE%{{!}}%TITLE%]] referenced by %PAGESEL%,
}}

If we set distinct=strict we will only get one result. Note that the value of %PAGESEL% in this case will be not useful.

Backlinks (52)

Code

{{#dpl:
|namespace=Help
|linksto={{PAGENAME}}{{!}}{{PAGENAME}}s{{!}}{{PAGENAME}}es{{!}}{{PAGENAME}}ies{{!}}{{PAGENAME}}ing{{!}}{{PAGENAME}}ed{{#if:{{{2}}}|{{!}}{{{2}}}{{!}}{{{2}}}s|}}{{#if:{{{3|}}}|{{!}}{{{3}}}{{!}}{{{3}}}s|}}
|resultsheader=<h2>Backlinks (%PAGES%)</h2>
|format=,\n*[[%PAGE%{{!}}%TITLE%]] referenced by %PAGESEL%,
|distinct=strict
}}