(Created page with "== Populating a dropdown with values from a (sub-) category == === Using DPL query === (Solution found at: https://www.mediawiki.org/wiki/Extension_talk:DynamicPageList3#Retu...") |
No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
== | == Providing input values from a (sub-) category == | ||
=== Using input type "tree" === | |||
(see official documentation: [[mediawikiwiki:Extension:Page_Forms/Input_types#tree|mediawiki.org/wiki/Extension:Page_Forms/Input_types#tree]] )<syntaxhighlight lang="text"> | |||
{{{field|doctype|input type=tree|top category=Document type|depth=1|hideroot|list}}} | |||
</syntaxhighlight>Form display: | |||
[[File:PF tree.png|alt=screenshot of category tree with one value selected|none|thumb|Field type tree]] | |||
=== Using DPL query === | |||
Example output of template parameter: <code>doctype=Process</code> | |||
=== Using DPL query (dropdown) === | |||
(Solution found at: https://www.mediawiki.org/wiki/Extension_talk:DynamicPageList3#Return_page_titles_as_plain_text?<syntaxhighlight lang="text"> | (Solution found at: https://www.mediawiki.org/wiki/Extension_talk:DynamicPageList3#Return_page_titles_as_plain_text?<syntaxhighlight lang="text"> | ||
{{{field | |||
| | | doctype | ||
| input type=dropdown | | input type=dropdown | ||
| values = {{#dpl: namespace = Category | | values = {{#dpl: namespace = Category | ||
| category = | | category = Document type | ||
| mode = inline | | mode = inline | ||
| format = ,¶%TITLE%,, | | format = ,¶%TITLE%,, | ||
Line 13: | Line 21: | ||
}} | }} | ||
}}} | }}} | ||
</syntaxhighlight> | </syntaxhighlight>Form field: | ||
[[File:PF-subcat-dpl.png|alt=screenshot of the dropdown result for the dpl3 solution|none|thumb|values provided by dpl3 parser function]] | |||
Example template output: | |||
<code>doctype=Process</code> | |||
Using an SMW inline query | |||
<syntaxhighlight lang="text"> | |||
{{{field|doctype|input type=dropdown|values={{#ask: [[Subcategory of::Document type]]|format=plainlist|sep=,|link=none|template=SMW Pagename}} }}} | |||
</syntaxhighlight>The above example uses the mapping template ''Template:SMW Pagename'' to avoid showing the namespace prefix "Category:" in the dropdown. Create the template with the following content:<syntaxhighlight lang="text"> | |||
{{PAGENAME:{{{1|}}} }} | |||
</syntaxhighlight>Although the category prefix is then not shown in the dropdown, the value the form passes to its associated template parameter still includes the namespace prefix. | |||
Example template output: | |||
<code>doctype=Process</code> | |||
=== Using an SMW concept === | |||
Create the page Concept:Doctype with the following content:<syntaxhighlight lang="text"> | |||
{{#concept: | |||
[[Subcategory of::Documenttype]][[Modification date::+]] | |||
|List of sub categories of the category Documenttype | |||
}} | |||
</syntaxhighlight>Use this concept as the source for the values of your field:<syntaxhighlight lang="text"> | |||
{{{field|doctype|input type=dropdown|values from concept=doctype|mapping template=catConcept}}} | |||
</syntaxhighlight>The above example uses the mapping template ''Template:catConcept'' to avoid showing the namespace prefix "Category:" in the dropdown. Create the template with the following content:<syntaxhighlight lang="text"> | |||
{{PAGENAME:{{{1|}}} }} | |||
</syntaxhighlight>Although the category prefix is then not shown in the dropdown, the value the form passes to its associated template parameter still includes the namespace prefix. | |||
Example template output: | |||
<code>doctype=Category:Process</code> |
Latest revision as of 07:55, 24 May 2023
Providing input values from a (sub-) category
Using input type "tree"
(see official documentation: mediawiki.org/wiki/Extension:Page_Forms/Input_types#tree )
{{{field|doctype|input type=tree|top category=Document type|depth=1|hideroot|list}}}
Form display:
Example output of template parameter: doctype=Process
Using DPL query (dropdown)
(Solution found at: https://www.mediawiki.org/wiki/Extension_talk:DynamicPageList3#Return_page_titles_as_plain_text?
{{{field
| doctype
| input type=dropdown
| values = {{#dpl: namespace = Category
| category = Document type
| mode = inline
| format = ,¶%TITLE%,,
| inlinetext = ,
}}
}}}
Form field:
Example template output:
doctype=Process
Using an SMW inline query
{{{field|doctype|input type=dropdown|values={{#ask: [[Subcategory of::Document type]]|format=plainlist|sep=,|link=none|template=SMW Pagename}} }}}
The above example uses the mapping template Template:SMW Pagename to avoid showing the namespace prefix "Category:" in the dropdown. Create the template with the following content:
{{PAGENAME:{{{1|}}} }}
Although the category prefix is then not shown in the dropdown, the value the form passes to its associated template parameter still includes the namespace prefix.
Example template output:
doctype=Process
Using an SMW concept
Create the page Concept:Doctype with the following content:
{{#concept:
[[Subcategory of::Documenttype]][[Modification date::+]]
|List of sub categories of the category Documenttype
}}
Use this concept as the source for the values of your field:
{{{field|doctype|input type=dropdown|values from concept=doctype|mapping template=catConcept}}}
The above example uses the mapping template Template:catConcept to avoid showing the namespace prefix "Category:" in the dropdown. Create the template with the following content:
{{PAGENAME:{{{1|}}} }}
Although the category prefix is then not shown in the dropdown, the value the form passes to its associated template parameter still includes the namespace prefix.
Example template output:
doctype=Category:Process