Parser Function semorg-list: Difference between revisions
Line 53: | Line 53: | ||
The default category is the content of <code>semorg-<feature>-category</code>. If you want to use a different category, you can overwrite the default using this parameter. | The default category is the content of <code>semorg-<feature>-category</code>. If you want to use a different category, you can overwrite the default using this parameter. | ||
You can also unset it with “<code>-</code>“ if you don't want to or cannot use a category for querying. You need to specify a <code>query | You can also unset it with “<code>-</code>“ if you don't want to or cannot use a category for querying. You need to specify a <code>query</code> then. | ||
==== {{semorg-parser-function-parameter|row template}} ==== | ==== {{semorg-parser-function-parameter|row template}} ==== |
Revision as of 20:54, 3 May 2019
This parser function is used to show lists of pages belonging to a certain category.
Markup | Result | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{#semorg-list:group}}
|
or actually: {{#ask:[[category:semorg-group]] |mainlabel=target |?semorg-group-name=name |?semorg-group-description=description |?semorg-group-type=type |?semorg-group-permanent=permanent |?semorg-group-active=active |?semorg-group-host=host |format=template |link=none |template=semorg-group-row |named args=yes |intro=<table class="table table-bordered table-sm"> <tr><th>Name</th><th>Description</th> <th>Host</th><th>Members</th></tr> |outro=</table> }} |
How it works
The parser function constructs a semantic {{#ask:}}
query using the result format template
. The template used to output the data can be customized using the row template
parameter. All the default fields for a feature will be passed to the template as named args.
Messages
The following system messages control the appearance of the list:
Message | Function |
---|---|
semorg-list-<feature>-headers | Should contain a list of message keys that contain the texts for the table headers. For the example above the content of semorg-list-group-headers is “group-name, group-description, group-host, group-members “. The elements of the list should have the general form of <feature>-<field> . The list is used to reference another set of messages following the naming convention semorg-field-<feature>-<field>-name . So semorg-field-group-name-name is used to populate the heading of the first column in the example above.
|
semorg-list-<feature>-row-template | Specify a global row template for all calls of {{#semorg-list:<feature>}} if it should be different from the default Template:semorg-<feature>-row . Note that you can leave out the “semorg-” and “-row“ parts of the template name.
|
Parameters
The following parameters are available:
category
The default category is the content of semorg-<feature>-category
. If you want to use a different category, you can overwrite the default using this parameter.
You can also unset it with “-
“ if you don't want to or cannot use a category for querying. You need to specify a query
then.
row template
The parser function constructs a query that calls a template for every row. The default value is the same as the name of the feature. The actual name of the template called should be semorg-<row template>-row
. You'll have to provide it on your own if you want to replace the default.
Note that the default message for the headers will change to semorg-list-<row template>-headers
instead of semorg-list-<feature>-headers
, if the message exists.
headers
Use this parameter to overwrite the default headers. It should be a comma separated list of <feature>-<field>
entries that will be expanded to semorg-field-<feature>-<field>-name
message calls.
query
You can add additional query conditions using Semantic MediaWiki's syntax. For example, if you would like to list only active groups, just add query=[[semorg-group-active::true]]
.
?<field-name>
By default, the parser function queries all fields that are defined for the feature and passes them on to the row template as named args. You can add custom lines to query for your custom fields or for chained properties. For example, if you would like to use the email address of the group's host in the row template you could add |?semorg-group-host.semorg-person-email=email
.
In order for this to work, you will need to use the row template
parameter to call your custom template, where you can then use {{{?email|}}}
to get the value. You can customize the headers if you also create a semorg-list-<row template>-headers
system message. If a message of that name doesn't exist, the default semorg-list-<feature>-headers
message will be used.
sort
, order
, default
, limit
These are the same as the standard parameters of {{#ask}}
queries.