Parser Function semorg-list

From SemanticOrganization
Jump to: navigation, search

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, userparam

These are the same as the standard parameters of {{#ask}} queries.

searchlabel

The searchlabel will be suppressed by default but can be explicitly set.

Markup Result
{{#semorg-list:group
  |limit=1
  |nopagination
}}
NameHostMembers
Former Group
inactive
this group isn't active any more
{{#semorg-list:group
  |limit=1
  |nopagination
  |searchlabel=Show Other Groups
}}
Show Other Groups
NameHostMembers
Former Group
inactive
this group isn't active any more

filters

All fields specified as <feature>-<field> can be used as query strings in URLs. That means that you can build links to a filtered version of the list.

filter_links

Fields specified with this parameter can not only be queried, the available values will also be shown as links for quick filtering.

You can set a default filter value using the <feature>-<field>=<default> syntax.

Markup Result
{{#semorg-list:group
  |filter links=group-host
}}

csv

This parameter creates a download link for a csv containing the fields specified (as a comma separated list of <field>.

Markup Result
{{#semorg-list:group
  |csv=name,description,host
}}

nopagination

Set this parameter if you don't want the pagination links to show up at the bottom of the table.

Markup Result
{{#semorg-list:group
  |limit=1
}}
NameHostMembers
Former Group
inactive
this group isn't active any more
{{#semorg-list:group
  |limit=1
  |nopagination
}}
NameHostMembers
Former Group
inactive
this group isn't active any more

­footer

Set this parameter if you want to show something below the list (preferably used together with nopagination).

Markup Result
{{#semorg-list:group
  |limit=1
}}
NameHostMembers
Former Group
inactive
this group isn't active any more
{{#semorg-list:group
  |limit=1
  |nopagination
  |footer=[[Groups|Show all groups]]
}}
NameHostMembers
Former Group
inactive
this group isn't active any more