Select by category-related criteria (examples): Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
imported>FrozenPlum
(Remove {{purgenote}} (no longer needed))
 
(21 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{DPL Manual|section=Examples|subsection=Select by Category}}
{{DPL manual|section=Examples|subsection=Select by category-related criteria (examples)}}
{{tocright}}


The examples on this page, all [[Criteria for page selection|select articles based on CATEGORY]] for output.
== Basic example ==


==category parameter==
The following example:


===Single category===
<pre><nowiki>{{#dpl:
<pre>
category=DPL
{{#dpl:
}}</nowiki></pre>
|category=Countries in North America
}}
</pre>


or
Would produce all the articles in the DPL category.


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

'''Result:'''<br>
<dpl>
category=Countries in North America
</dpl>


===Logical OR===
Using pipe (or pipe replacement) for logical '''OR''':
<pre>
{{#dpl:
{{#dpl:
|category=Countries in Africa¦Countries in North America¦Countries in United Kingdom
category=DPL
|namespace=
}}
}}
</pre>


or
== Further examples of syntax ==


<pre>
To find all articles that feature two category names, an example would be:
<dpl>
category=Countries in Africa|Countries in North America|Countries in United Kingdom
namespace=
</dpl>
</pre>


'''Result:'''<br>
<pre><nowiki>
<DPL>
<dpl>
category=Countries in Africa|Countries in North America|Countries in United Kingdom
category = Chair
namespace=
category = Wood
</DPL>
</dpl>
</nowiki></pre>


Or to find all articles that contain one category name, and then another category name from two possible options, would be:


===Logical AND with logical OR===
<pre><nowiki>
Logical '''OR''' with logical '''AND''' by using a second category statement.
<DPL>
<pre>
category = Chair
{{#dpl:
category = Wood | Metal
|category=Countries in North America¦Countries in United Kingdom
</DPL>
|category=Part of NATO
</nowiki></pre>
}}</pre>
{| class="wikitable mw-collapsible mw-collapsed"
! Other invocation examples
|-
|
'''Parser function''' invocation <code><nowiki>{{#dpl:}}</nowiki></code> with pipe escaped via <code><nowiki>{{!}}</nowiki></code> [[mw:Help:Magic words#Other|magic word]]:
<pre>
{{#dpl:
|category=Countries in North America{{!}}Countries in United Kingdom‎
|category=Part of NATO
}}
</pre>


or
To sort results alphabetically:

Tag/parser extension invocation <code><nowiki><dpl></dpl></nowiki></code> (where regular pipe can be used because there's no pipe to set the ''category'' parameter):
<pre>
<dpl>
category=Countries in North America|Countries in Europe
category=NATO membership debates‎
</dpl>
</pre>
{{note|Tag/parser extension {{DPL|syntax}} is simpler, but much less flexible than parser function <code><nowiki>{{#dpl:}}</nowiki></code> syntax.}}
|}

'''Result''' (identical output regardless of invocation method):<br>

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


===Include direct subcategories===
If you put a <code><nowiki>*</nowiki></code> before the name of a category, DPL will add all DIRECT subcategories of that category to your statement.
Using TWO asterisks ( <code><nowiki>**</nowiki></code> ) 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.

<pre>
{{#dpl:
|category=+Countries in Africa¦Countries in Europe
|category=*Part of NATO
|headingmode=ordered
|ordermethod=category,sortkey
}}
</pre>

'''Result:'''<br>

{{#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:

<pre>
{{#dpl:
|category = Country examples
|category = Part of NATO‎
}}
</pre>

'''Result:'''<br>
{{#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:

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

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


==categorymatch parameter==

===Begins with===
Wildcard <code>%</code> at the end means the word must begin with whatever was specified, the ending can be anything.
<pre>
{{#dpl:
|categorymatch=Countries%
|count=3
}}
</pre>

or

<pre>
<dpl>
categorymatch=Countries%
count=3
</dpl>
</pre>
This selects pages that belong to any category name that begins with "Countries" (such as those in [[:Category:Country examples]]), limited to a result count of 3.


'''Result:'''
{{#dpl:
|categorymatch=Countries%
|count=3
}}


===Ends with===
Wildcard <code>%</code> at the beginning means the word must end with whatever was specified, the beginning can be anything.

<pre>
{{#dpl:
|categorymatch=%output pages
|count=4
}}
</pre>

or

<pre>
<dpl>
titlematch=%output pages
</dpl>
</pre>
This selects pages that belong to any category name that ends with "output pages" (such as those pages belonging to one of the categories in [[:Category:Demo output pages]]).


'''Result:'''
{{#dpl:
|categorymatch=%output pages
}}


===Contains===
Using a <code>%</code> (wildcard) '''on either side''' of an {{DPL|categorymatch}} argument, selects pages that belong to a category where the specified characters are found '''anywhere''' in the category name.
<pre>
{{#dpl:
|categorymatch=%demo%
|count=3
}}
</pre>

or

<pre>
<dpl>
categorymatch=%demo%
count=3
</dpl>
</pre>
This selects pages that belong to a category name that contains "demo" such as [[:Category:Miscellaneous demo examples]], though it does not match pages in [[:Category:Demo output pages]] because {{DPL|categorymatch}} is case-sensitive. Results in this example are limited to a count of 3.


'''Result:'''
{{#dpl:
|categorymatch=%demo%
|count=3
}}

===Keeping spaces at beginning or end===

Normally, if a space was in the middle of a {{DPL|categorymatch}} statement it would automatically escape it by inserting a <code>\</code> in front; however, when spaces are used at the beginning or end of a {{DPL|categorymatch}} statement, they must manually be escaped. For example, if we wanted to search for items by <code>%&nbsp;in&nbsp;%</code>, we would need to escape the spaces <code>\&nbsp;in\&nbsp;</code> to keep them.

<pre>
{{#dpl:
|category = Country examples
|categorymatch = %\ in\ %
|count = 5
}}
</pre>

or

<pre>
<dpl>
categorymatch = %\ in\ %
category = Country examples
count = 5
</dpl>
</pre>
This selects pages that belong to a category that has <code>&nbsp;in&nbsp;</code> '''anywhere''' in any category name, such as [[:Category:Countries in Africa]], [[:Category:Countries in Europe]], and [[:Category:Countries in North America]], and that are in [[:Category:Country examples]], limited to a {{DPL|count}} of 5 results.


'''Result:'''
{{#dpl:
|category = Country examples
|categorymatch=%\ in\ %
|count=5
}}


===Multiple criteria===
Using <code>%</code> (wildcard) on either side, for letters anywhere in a category name:
<pre>
{{#dpl:
|categorymatch=%ruit%¦%esse%
|count=6
}}
</pre>

or

<pre>
<dpl>
categorymatch=%ruit%¦%esse%
count=6
</dpl>
</pre>


'''Result:'''

{{#dpl:
|categorymatch=%ruit%¦%esser%
|count=6
|order = ascending
}}
This selects pages that belong to a category that has "ruit" or "esser" in the category name, such as [[:Category:Fruit examples]] and [[:Category:Dessert examples]], limited to a {{DPL|count}} of 6 results.


==Other==
{{note|These examples will be moved elsewhere, once their respective pages are created.}}
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".
<pre>
{{#dpl:
|category = Part of NATO‎
|ordermethod = titlewithoutnamespace
|order = ascending
}}
</pre>

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


[[Category:Criteria for page selection (examples)]]
<pre><nowiki>
<DPL>
category = Chair
ordermethod = titlewithoutnamespace
order = ascending
</DPL>
</nowiki></pre>

Latest revision as of 23:34, 16 January 2023

Manual Examples Select by category-related criteria (examples)

The examples on this page, all select articles based on CATEGORY for output.

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
|ordermethod=category,sortkey
}}

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‎ }}


categorymatch parameter

Begins with

Wildcard % at the end means the word must begin with whatever was specified, the ending can be anything.

{{#dpl:
|categorymatch=Countries%
|count=3
}}

or

<dpl>
 categorymatch=Countries%
 count=3
</dpl>

This selects pages that belong to any category name that begins with "Countries" (such as those in Category:Country examples), limited to a result count of 3.


Result: {{#dpl: |categorymatch=Countries% |count=3 }}


Ends with

Wildcard % at the beginning means the word must end with whatever was specified, the beginning can be anything.

{{#dpl:
|categorymatch=%output pages
|count=4
}}

or

<dpl>
 titlematch=%output pages
</dpl>

This selects pages that belong to any category name that ends with "output pages" (such as those pages belonging to one of the categories in Category:Demo output pages).


Result: {{#dpl: |categorymatch=%output pages }}


Contains

Using a % (wildcard) on either side of an categorymatch argument, selects pages that belong to a category where the specified characters are found anywhere in the category name.

{{#dpl:
|categorymatch=%demo%
|count=3
}}

or

<dpl>
 categorymatch=%demo%
 count=3
</dpl>

This selects pages that belong to a category name that contains "demo" such as Category:Miscellaneous demo examples, though it does not match pages in Category:Demo output pages because categorymatch is case-sensitive. Results in this example are limited to a count of 3.


Result: {{#dpl: |categorymatch=%demo% |count=3 }}

Keeping spaces at beginning or end

Normally, if a space was in the middle of a categorymatch statement it would automatically escape it by inserting a \ in front; however, when spaces are used at the beginning or end of a categorymatch statement, they must manually be escaped. For example, if we wanted to search for items by % in %, we would need to escape the spaces \ in\  to keep them.

{{#dpl:
|category = Country examples
|categorymatch = %\ in\ %
|count = 5
}}

or

<dpl>
 categorymatch = %\ in\ %
 category = Country examples
 count = 5
</dpl>

This selects pages that belong to a category that has  in  anywhere in any category name, such as Category:Countries in Africa, Category:Countries in Europe, and Category:Countries in North America, and that are in Category:Country examples, limited to a count of 5 results.


Result: {{#dpl: |category = Country examples |categorymatch=%\ in\ % |count=5 }}


Multiple criteria

Using % (wildcard) on either side, for letters anywhere in a category name:

{{#dpl:
|categorymatch=%ruit%¦%esse%
|count=6
}}

or

<dpl>
 categorymatch=%ruit%¦%esse%
 count=6
</dpl>


Result:

{{#dpl: |categorymatch=%ruit%¦%esser% |count=6 |order = ascending }} This selects pages that belong to a category that has "ruit" or "esser" in the category name, such as Category:Fruit examples and Category:Dessert examples, limited to a count of 6 results.


Other

These examples will be moved elsewhere, once their respective pages are created.

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 }}