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}}
NameHostMembers
Former Group
inactive
this group isn't active any more
John Doe
Testgroup
describing the group
John Doe Jane Doe
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testing numbered group names
Jane Doe John Doe, Jane Doe
Testing numbered groups
Group's description
Jane Doe Ad Min
Former Group
inactive
this group isn't active any more
Testgroup
describing the group
Testgroup 2
Group for testing purposes
Testing numbered group names
Testing numbered groups
Group's description

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.
semorg-list-<feature>-all-link-text The link text for the footer when using the all url parameter.
semorg-list-<feature>-custom-tableclass Use custom css classes for the table. (The default classes are table table-sm table-bordered sortable).
semorg-list-<feature>-sums See sums parameter below

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.

To completely hide the headers use headers=-.

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, intro, outro, limit, userparam

These are the same as the standard parameters of {{#ask}} queries. They can also be defined globally using messages (e.g. semorg-list-<feature>-sort).

searchlabel

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

Markup Result
{{#semorg-list:group
  |limit=1
  |nopagination
}}
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes
{{#semorg-list:group
  |limit=1
  |nopagination
  |searchlabel=Show Other Groups
}}
Show Other Groups
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Show Other Groups
Testgroup 2
Group for testing purposes

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
}}
NameHostMembers
Former Group
inactive
this group isn't active any more
John Doe
Testgroup
describing the group
John Doe Jane Doe
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testing numbered group names
Jane Doe John Doe, Jane Doe
Testing numbered groups
Group's description
Jane Doe Ad Min
Former Group
inactive
this group isn't active any more
Testgroup
describing the group
Testgroup 2
Group for testing purposes
Testing numbered group names
Testing numbered groups
Group's description

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
}}
NameHostMembers
Former Group
inactive
this group isn't active any more
John Doe
Testgroup
describing the group
John Doe Jane Doe
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testing numbered group names
Jane Doe John Doe, Jane Doe
Testing numbered groups
Group's description
Jane Doe Ad Min
Former Group
inactive
this group isn't active any more
Testgroup
describing the group
Testgroup 2
Group for testing purposes
Testing numbered group names
Testing numbered groups
Group's description

map-template

Show a map above the list. The parameter defines a template that will be used to define the content of the tooltip. There needs to be a property of the type Geographic coordinates and the Maps Extension needs to be installed in order for this to work.

heading

This is used on detail pages to set the main heading for the page.

help

If set a help sign will be shown next to the heading, linking to a help page.

title

The title will be shown above the list.

formlink

Contains the link to the form to create new instances of the feature. {{#semorg-formlink}} can be used to create the link.

links

The links will be shown above the list but below a header.

sums

Show a bottom row with sums for numerical columns.

Markup Result
{{#semorg-list:role-metric-measurement
  |?semorg-role-metric-measurement-metric
  .semorg-role-metric-frequency=frequency
  |limit=1
  |nopagination
}}
DateAuthorValue
2019 (19/08/24) Ad Min
5
{{#semorg-list:role-metric-measurement
  |?semorg-role-metric-measurement-metric
  .semorg-role-metric-frequency=frequency
  |limit=1
  |sums=,,role-metric-measurement-value
  |nopagination
}}
DateAuthorValue
2019 (19/08/24) Ad Min
5
3,122

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
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes
{{#semorg-list:group
  |limit=1
  |nopagination
}}
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes

­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
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes
{{#semorg-list:group
  |limit=1
  |nopagination
  |footer=[[Groups|Show all groups]]
}}
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes

­all url

If the footer should contain a link to a complete list of items it can also be constructed using this parameter. It should contain the url of the target page. It will use semorg-list-<feature>-all-link-text for the link text or semorg-list-default-all-link-text if it's not available. The link will only be displayed if the number of items is higher than the number of items shown. The total number of items is available as parameter in the messages.

Markup Result
{{#semorg-list:group
  |limit=1
}}
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes
{{#semorg-list:group
  |limit=1
  |nopagination
  |all url={{fullurl:Groups}}
}}
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes

­collapsed

Hide the list by default, only show it after clicking the arrow symbol. Only works together with a title.

Markup Result
{{#semorg-list:group
  |limit=1
  |title=Groups
  |collapsed=some-unique-id
  |nopagination
}}
Groups
NameHostMembers
Testgroup 2
Group for testing purposes
Jane Doe Jane Doe, John Doe
Testgroup 2
Group for testing purposes