Select by category-related criteria (examples)

From DynamicPageList3 Manual
Revision as of 04:16, 7 April 2022 by imported>FrozenPlum

category parameter

Single category

{{#dpl:
|category=Countries in North America
}}

or

<dpl>
 category=Countries in North America
</dpl>

Result:
<dpl>

category=Countries in North America

</dpl>


Logical OR

Using pipe (or pipe replacement) for logical OR:

{{#dpl:
|category=Countries in Africa¦Countries in North America¦Countries in United Kingdom
|namespace=
}}

or

<dpl>
 category=Countries in Africa|Countries in North America|Countries in United Kingdom
 namespace=
</dpl>

Result:
<dpl>

category=Countries in Africa|Countries in North America|Countries in United Kingdom
namespace=

</dpl>


Logical AND with logical OR

Logical OR with logical AND by using a second category statement.

{{#dpl:
|category=Countries in North America¦Countries in United Kingdom
|category=Part of NATO
}}
Other invocation examples

Parser function invocation {{#dpl:}} with pipe escaped via {{!}} magic word:

{{#dpl:
|category=Countries in North America{{!}}Countries in United Kingdom‎
|category=Part of NATO
}}

or

Tag/parser extension invocation <dpl></dpl> (where regular pipe can be used because there's no pipe to set the category parameter):

<dpl>
category=Countries in North America|Countries in Europe
category=NATO membership debates‎ 
</dpl>
Tag/parser extension syntax is simpler, but much less flexible than parser function {{#dpl:}} syntax.

Result (identical output regardless of invocation method):

{{#dpl: |category=Countries in North America¦Countries in United Kingdom |category=Part of NATO }}


Include direct subcategories

If you put a * before the name of a category, DPL will add all DIRECT subcategories of that category to your statement. Using TWO asterisks ( ** ) will extend the tree search to two levels. This provides some minimal support for hierarchies of categories. The syntax and/or semantics of this feature might be changed in a future version.

{{#dpl:
|category=+Countries in Africa¦Countries in Europe
|category=*Part of NATO
|headingmode=ordered
}}
For unknown reasons, if the ordermethod parameter is set with the value category,sortkey it breaks this example, causing it to display no output; thus it has been removed from the example.

Result:

{{#dpl: |category=+Countries in Europe¦Countries in Africa |category=*Part of NATO |headingmode=ordered }}


Must be in 2 categories

To find all articles that are in two category, such as all Country examples and Part of NATO, an example would be:

{{#dpl:
|category = Country examples
|category = Part of NATO‎ 
}}

Result:
{{#dpl: |category = Country examples |category = Part of NATO‎ }}


Must be in 1 category and another (one of multiple)

Or to find all articles that contain one category name, and then another category name from two possible options, such as listing all the chairs that are made of wood as well as all the chairs that are made of metal, would be:

{{#dpl:
|category = Country examples
|category = NATO membership debates‎  | Part of NATO‎ 
}}

Result:
{{#dpl: |category = Country examples |category = NATO membership debates‎ | Part of NATO‎ }}


Sorting results alphabetically

Sort articles alphabetically, disregarding the namespace in the order (sorting for "Category:NATO membership debates" would sort by the "N" in "NATO" rather than the "C" in "Category".

{{#dpl:
|category = Part of NATO‎
|ordermethod = titlewithoutnamespace
|order = ascending
}}

Result:
{{#dpl: |category = Part of NATO‎ |ordermethod = titlewithoutnamespace |order = ascending }}