Parser Functions: Difference between revisions

From SemanticOrganization
Jump to: navigation, search
 
(54 intermediate revisions by the same user not shown)
Line 23: Line 23:
sets all the attributes and spits out a nicely formatted table with all the contact information and also a download link for a .vcard file
sets all the attributes and spits out a nicely formatted table with all the contact information and also a download link for a .vcard file


=== #semorg-field ===
=== #semorg-field-rows ===


Returns the markup for a field in a form.
Returns the markup for the fields in a form.


{| class="table table-bordered table-condensed"
{| class="table table-bordered table-condensed"
! Markup !! Result
! Markup !! Result
|-
|-
|<pre><nowiki>{{#semorg-field:name
|<pre><nowiki>{{#semorg-field-rows:name
   |template=person
   |template=person
}}</nowiki></pre>
}}</nowiki></pre>
|<code>{{#semorg-field:name|template=person}}</code>
|''only works in form definitions''
|}
|}


Line 75: Line 75:
|}
|}


=== #semorg-fields ===
=== #semorg-set ===


=== #semorg-field-rows ===
Shorthand for <code><nowiki>{{#set:}}</nowiki></code>


=== #semorg-set ===
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<pre><nowiki>{{#semorg-set:person
  |name={{{name|}}}
}}</nowiki></pre>
|<pre><nowiki>{{#set:
  |semorg-person-name={{{name|}}}
}}</nowiki></pre>
|}


=== #semorg-set-list ===
=== #semorg-set-list ===


=== #semorg-table ===
Shorthand for <code><nowiki>{{#set:}}</nowiki></code> for properties with multiple values.
 
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<pre><nowiki>{{#semorg-set-list:person
  |name={{{name|}}}
}}</nowiki></pre>
|<pre><nowiki>{{#set:
  |semorg-person-name={{{name|}}}|+sep=,
}}</nowiki></pre>
|}


=== #semorg-subobject ===
=== #semorg-subobject ===


=== #semorg-network ===
Shorthand for <code><nowiki>{{#subobject:}}</nowiki></code>.
 
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<pre><nowiki>{{#semorg-subobject:person
  |name={{{name|}}}
}}</nowiki></pre>
|<pre><nowiki>{{#subobject:
  |semorg-person-name={{{name|}}}|+sep=,
}}</nowiki></pre>
|}
 
=== #semorg-table ===


=== #semorg-cooperation ===
Rendering template parameters (or other content) as a table. Field names are used for the first column.


=== #semorg-circles ===
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<pre><nowiki>{{#semorg-table:person
  |name={{{name|Dummy Person}}}
}}</nowiki></pre>
|{{#semorg-table:person
  |name={{{name|Dummy Person}}}
}}
|}


=== #semorg-toggle ===
=== #semorg-toggle ===
Rendering template parameters (or other content) as a table. Field names are used for the first column.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<pre><nowiki>{{#semorg-toggle:
  |class=semorg-toggle-test
  |original-text=hide it
  |toggle-text=show it
}}
<div class="semorg-toggle-test">
Text to be toggled
</div></nowiki></pre>
|{{#semorg-toggle:
  |class=semorg-toggle-test
  |original-text=hide it
  |toggle-text=show it
}}<div class="semorg-toggle-test">
Text to be toggled
</div>
|-
|<pre><nowiki>{{#semorg-toggle:
  |class=semorg-toggle-hidden-test
  |original-text=show it
  |toggle-text=hide it
}}
<div class="semorg-toggle-hidden-test" style="display:none">
Initially hidden
</div></nowiki></pre>
|{{#semorg-toggle:
  |class=semorg-toggle-hidden-test
  |original-text=show it
  |toggle-text=hide it
}}<div class="semorg-toggle-hidden-test" style="display:none">
Initially hidden
</div>
|}


=== #semorg-list ===
=== #semorg-list ===


This parser function is used to show lists of pages belonging to a certain category. For the details about this highly configurable parser function see [[Parser Function semorg-list]]
This parser function is used to show lists of pages belonging to a certain category. For the details about this highly configurable parser function see [[Parser Function semorg-list]]
=== #semorg-overview ===
This parser function is used to create calls to  <code><nowiki>{{#semorg-list:}}</nowiki></code> using defaults partly defined by system messages.
As an example the call <code><nowiki>{{#semorg-list:person-contact}}</nowiki></code> will be translated into:
<nowiki>{{#semorg-list:person
  |category=semorg-person-contact
  |row template=person-contact
  |links={{#ifexist:Template:semorg-person-contact-custom-links
    |{{semorg-person-contact-custom-links}}
    |{{#ifexist:Template:semorg-person-contact-links
      |{{semorg-person-contact-links}}
    }}
  }}
  |heading={{int:semorg-person-contact-page-name}}
  |formlink={{#semorg-formlink:person-contact}}
}}</nowiki>
Behind the scenes it is using the following pre-defined system messages:
* semorg-overview-person-contact-parent-feature (“person”)
* semorg-overview-person-contact-row-template (“person-contact”)
* semorg-overview-person-contact-category (“semorg-person-contact”)


=== #semorg-user-create ===
=== #semorg-user-create ===


Render a link to create a new user account if it doesn't exist already
Render a link to create a new user account if it doesn't exist already
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<pre><nowiki>{{#semorg-user-create:Dummy User}}</nowiki></pre>
|{{#semorg-user-create:Dummy User}}
|}


=== #semorg-formlink ===
=== #semorg-formlink ===
Line 110: Line 221:
! Markup !! Result
! Markup !! Result
|-
|-
|<code><nowiki>{{#semorg-formlink:meeting}}</nowiki></code>
|<code><nowiki>{{#semorg-formlink:meeting-group}}</nowiki></code>
|{{#semorg-formlink:meeting}}
|{{#semorg-formlink:meeting-group}}
|}
|}


Line 209: Line 320:


=== #semorg-meetings ===
=== #semorg-meetings ===
This is a shorthand to display
* a link to create a new meeting
* a list of scheduled meetings
* a list of recent meetings
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-meetings:group
  |group=Testgroup
}}</nowiki></code>
|{{#semorg-meetings:group|group=Testgroup}}
|}
The following system messages control the appearance:
{| class="table table-bordered table-condensed"
! Message !! Function
|-
|semorg-list-meeting-current-heading
|The heading for the list of current meetings
|-
|semorg-list-meeting-past-heading
|The heading for the list of recent meetings
|}
The following parameters are available:
{| class="table table-bordered table-condensed"
! Parameter !! Description
|-
|group
|If the group is not explicitly set it is assumed to be the title of the current page. You can set it to '+' if you want no specific group.
|}


=== #semorg-properties ===
=== #semorg-properties ===
Show a feature's properties/fields.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-properties:group}}</nowiki></code>
|{{#semorg-properties:group}}
|}


=== #semorg-values ===
=== #semorg-values ===
Render all values for a specific property.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-values:person-name}}</nowiki></code>
|
{{#semorg-values:person-name}}
<small>this is the result of the following code: <pre><nowiki>
{{#ask:[[semorg-person-name::+]]
  |mainlabel=-
  |headers=hide
  |limit=1000
  |searchlabel=
  |?semorg-person-name#
}}</nowiki></pre></small>
|}


=== #semorg-tabs ===
=== #semorg-tabs ===
Line 239: Line 413:


=== #semorg-user ===
=== #semorg-user ===
Show the current user.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-user:}}</nowiki></code>
|
{{#semorg-user:}}
|}


=== #semorg-true ===
=== #semorg-true ===
Test whether the first argument is one of SMW's true words.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-true:yes|true|false}}</nowiki></code><br>
<code><nowiki>{{#semorg-true:nope|true|false}}</nowiki></code>
|
{{#semorg-true:yes|true|false}}<br>
{{#semorg-true:nope|true|false}}
|}


=== #semorg-detail ===
=== #semorg-detail ===
Line 265: Line 461:
|heading
|heading
|Heading to be displayed instead of the standard heading. Will also call <code><nowiki>{{DISPLAYTITLE:}}</nowiki></code>.
|Heading to be displayed instead of the standard heading. Will also call <code><nowiki>{{DISPLAYTITLE:}}</nowiki></code>.
|-
|overview page
|Page that should be linked to as the parent page.
|}
|}
=== #semorg-datediff ===
Return the difference of two given datetimes. The function's optional third argument defines the unit and can have the values <code>days</code>, <code>hours</code> (the default), <code>minutes</code>, or <code>seconds</code>.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-datediff:{{#time:c}}|{{#time:c|+1 day}}}}</nowiki></code>
|{{#semorg-datediff:{{#time:c}}|{{#time:c|+1 day}}}}
|}
=== #semorg-datediff-human ===
Return the difference of a given past datetime to the current time as readable for humans (“x ago“).
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-datediff-human:{{#time:c|+100 days}}}}</nowiki></code>
|{{#semorg-datediff-human:{{#time:c|-100 days}}}}
|}
=== #semorg-counter ===
Return an incrementing counter (can be used to create unique IDs).
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-counter:}}</nowiki></code>
|{{#semorg-counter:}}
|}
=== #semorg-hash ===
Return MD5-Hash for given string.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-hash:test}}</nowiki></code>
|{{#semorg-hash:test}}
|}
=== #semorg-count ===
Return number of array entries (using explode). The separator is an optional second parameter.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-count:entry1,entry2}}</nowiki></code>
|{{#semorg-count:entry1,entry2}}
|-
|<code><nowiki>{{#semorg-count:entry1;entry2, including comma|;}}</nowiki></code>
|{{#semorg-count:entry1;entry2, including comma|;}}
|}
=== #semorg-query ===
Get query value (from URL). Use [{{fullurl:{{FULLPAGENAME}}##semorg-query|test=test}} this link] to see the effect.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-query:test}}</nowiki></code>
|{{#semorg-query:test}}
|}
=== #semorg-phone ===
Render phone number in Semantic MediaWiki format. The default country code is set via [[MediaWiki:Semorg-default-country-code]].
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-phone:0699/1234567}}</nowiki></code>
| {{#semorg-phone:0699/1234567}}
|}
=== #semorg-nocache ===
Can be used to disable caching on a page.
=== #semorg-sum ===
Add amounts and return the sum by leaving out the amount parameter.
{| class="table table-bordered table-condensed"
! Markup !! Result
|-
|<code><nowiki>{{#semorg-sum:test|5}}{{#semorg-sum:test|10}}{{#semorg-sum:test}}</nowiki></code>
| {{#semorg-sum:test|5}}{{#semorg-sum:test|10}}{{#semorg-sum:test}}
|}
== Visualization ==
=== #semorg-network ===
''tbd''
=== #semorg-cooperation ===
''tbd''
=== #semorg-circles ===
''tbd''

Latest revision as of 06:47, 14 November 2024

#semorg-person

called like this (preferably via template):

{{#semorg-person:
 |ref={{FULLPAGENAME}}
 |prefix={{{prefix|}}}
 |firstname={{{firstname|}}}
 |lastname={{{lastname|}}}
 |name={{{firstname|}}} {{{lastname|}}}
 |suffix={{{suffix|}}}
 |workstreet={{{workstreet|}}}
 |workpostalcode={{{workpostalcode|}}}
 |worklocality={{{worklocality|}}}
 |email={{{email|}}}
 |workphone={{{workphone|}}}
 |homepage={{{homepage|}}}
 |note={{{note|}}}
 |organization={{{organization|}}}
 |gender={{{gender|}}}
}}

sets all the attributes and spits out a nicely formatted table with all the contact information and also a download link for a .vcard file

#semorg-field-rows

Returns the markup for the fields in a form.

Markup Result
{{#semorg-field-rows:name
  |template=person
}}
only works in form definitions

The following system messages control the appearance of the list:

Message Function
semorg-field-<feature>-<field>-parameters Any of Page Form's parameters for fields.
semorg-field-<feature>-<field>-placeholder
semorg-field-<feature>-<field>-input-type
semorg-field-<feature>-<field>-values
semorg-field-<feature>-<field>-mapping-template
semorg-field-<feature>-<field>-class
semorg-field-<feature>-<field>-prefix Content to be displayed before the field.
semorg-field-<feature>-<field>-suffix Content to be displayed after the field.

The following parameters are available:

Parameter Description
template The name of the feature.

#semorg-set

Shorthand for {{#set:}}

Markup Result
{{#semorg-set:person
  |name={{{name|}}}
}}
{{#set:
  |semorg-person-name={{{name|}}}
}}

#semorg-set-list

Shorthand for {{#set:}} for properties with multiple values.

Markup Result
{{#semorg-set-list:person
  |name={{{name|}}}
}}
{{#set:
  |semorg-person-name={{{name|}}}|+sep=,
}}

#semorg-subobject

Shorthand for {{#subobject:}}.

Markup Result
{{#semorg-subobject:person
  |name={{{name|}}}
}}
{{#subobject:
  |semorg-person-name={{{name|}}}|+sep=,
}}

#semorg-table

Rendering template parameters (or other content) as a table. Field names are used for the first column.

Markup Result
{{#semorg-table:person
  |name={{{name|Dummy Person}}}
}}
Name

Dummy Person

#semorg-toggle

Rendering template parameters (or other content) as a table. Field names are used for the first column.

Markup Result
{{#semorg-toggle:
  |class=semorg-toggle-test
  |original-text=hide it
  |toggle-text=show it
}}
<div class="semorg-toggle-test">
Text to be toggled
</div>

Text to be toggled

{{#semorg-toggle:
  |class=semorg-toggle-hidden-test
  |original-text=show it
  |toggle-text=hide it
}}
<div class="semorg-toggle-hidden-test" style="display:none">
Initially hidden
</div>

#semorg-list

This parser function is used to show lists of pages belonging to a certain category. For the details about this highly configurable parser function see Parser Function semorg-list

#semorg-overview

This parser function is used to create calls to {{#semorg-list:}} using defaults partly defined by system messages.

As an example the call {{#semorg-list:person-contact}} will be translated into:

{{#semorg-list:person
  |category=semorg-person-contact
  |row template=person-contact
  |links={{#ifexist:Template:semorg-person-contact-custom-links
    |{{semorg-person-contact-custom-links}}
    |{{#ifexist:Template:semorg-person-contact-links
      |{{semorg-person-contact-links}}
    }}
  }}
  |heading={{int:semorg-person-contact-page-name}}
  |formlink={{#semorg-formlink:person-contact}}
}}

Behind the scenes it is using the following pre-defined system messages:

  • semorg-overview-person-contact-parent-feature (“person”)
  • semorg-overview-person-contact-row-template (“person-contact”)
  • semorg-overview-person-contact-category (“semorg-person-contact”)

#semorg-user-create

Render a link to create a new user account if it doesn't exist already

Markup Result
{{#semorg-user-create:Dummy User}}

#semorg-formlink

This parser function is an abbreviation to call {{#formlink}} with smart defaults.

Markup Result
{{#semorg-formlink:meeting-group}} Create Meeting

The following system messages control the appearance of the list:

Message Function
semorg-formlink-<feature>-link-text The link text to be displayed.
semorg-formlink-<feature>-link-type Use this to set a wiki-wide default for all calls of {{#semorg-formlink:<feature>}}
semorg-formlink-<feature>-target
semorg-formlink-<feature>-tooltip
semorg-formlink-<feature>-popup
semorg-formlink-<feature>-new-window
semorg-formlink-<feature>-query-string
semorg-formlink-<feature>-returnto

The following parameters are available:

Parameter Description
link text, link type, target, tooltip, popup, new window, query string, returnto These are the default parameters for Page Form's {{#formlink}} function

#semorg-forminput

This parser function is an abbreviation to call {{#forminput}} with smart defaults.

Markup Result
{{#semorg-forminput:group}}

The following system messages control the appearance of the list:

Message Function
semorg-forminput-<feature>-button-text The button text to be displayed.
semorg-forminput-<feature>-size Use this to set a wiki-wide default for all calls of {{#semorg-forminput:<feature>}}
semorg-forminput-<feature>-default-value
semorg-forminput-<feature>-query-string
semorg-forminput-<feature>-autocomplete-on-category
semorg-forminput-<feature>-autocomplete-on-namespace
semorg-forminput-<feature>-placeholder
semorg-forminput-<feature>-popup
semorg-forminput-<feature>-returnto

The following parameters are available:

Parameter Description
button text, size, default value, query string, autocomplete on category, autocomplete on namespace, placeholder, popup, returnto These are the default parameters for Page Form's {{#forminput}} function

NB: The no autofocus parameter is set by default.

#semorg-meetings

This is a shorthand to display

  • a link to create a new meeting
  • a list of scheduled meetings
  • a list of recent meetings
Markup Result
{{#semorg-meetings:group |group=Testgroup }}
Scheduled Group Meetings
no meetings scheduled…
no meetings scheduled…
Past Group Meetings
GroupDateLocationModeratorSecretaryParticipants
Testgroup
20/07/21

The following system messages control the appearance:

Message Function
semorg-list-meeting-current-heading The heading for the list of current meetings
semorg-list-meeting-past-heading The heading for the list of recent meetings

The following parameters are available:

Parameter Description
group If the group is not explicitly set it is assumed to be the title of the current page. You can set it to '+' if you want no specific group.

#semorg-properties

Show a feature's properties/fields.

Markup Result
{{#semorg-properties:group}} domain, co-host, description, goals, name, host, permanent, active

#semorg-values

Render all values for a specific property.

Markup Result
{{#semorg-values:person-name}}

ACME Corp., Ad Min, Brad Pitt, Darth Vader, Jane Doe, John Doe, Luke Skywalker, UNO

this is the result of the following code:
{{#ask:[[semorg-person-name::+]]
  |mainlabel=- 
  |headers=hide 
  |limit=1000 
  |searchlabel= 
  |?semorg-person-name# 
}}

#semorg-tabs

Creates togglable tabs.

The following system messages control the appearance of the header:

Message Function
semorg-tab-<feature>-<tab-id> The link text for the tab.

The following parameters are available:

Parameter Description
?<tab-id>=<tab-content> ID and content for a tab.

#semorg-tabs-card

#semorg-user

Show the current user.

Markup Result
{{#semorg-user:}}

User:192.168.0.1

#semorg-true

Test whether the first argument is one of SMW's true words.

Markup Result
{{#semorg-true:yes|true|false}}

{{#semorg-true:nope|true|false}}

true
false

#semorg-detail

Show header details for page. Replaces the main heading and provides a backlink to the overview page. See the documentation for Detail pages.

The following system messages control the appearance of the header:

Message Function
semorg-<feature>-page-name The title of the overview page
semorg-<feature>-entity name Name for the instance. Displayed over the page title.

The following parameters are available:

Parameter Description
heading Heading to be displayed instead of the standard heading. Will also call {{DISPLAYTITLE:}}.
overview page Page that should be linked to as the parent page.

#semorg-datediff

Return the difference of two given datetimes. The function's optional third argument defines the unit and can have the values days, hours (the default), minutes, or seconds.

Markup Result
{{#semorg-datediff:{{#time:c}}|{{#time:c|+1 day}}}} 24

#semorg-datediff-human

Return the difference of a given past datetime to the current time as readable for humans (“x ago“).

Markup Result
{{#semorg-datediff-human:{{#time:c|+100 days}}}} 3 months ago

#semorg-counter

Return an incrementing counter (can be used to create unique IDs).

Markup Result
{{#semorg-counter:}} 1

#semorg-hash

Return MD5-Hash for given string.

Markup Result
{{#semorg-hash:test}} 098f6bcd4621d373cade4e832627b4f6

#semorg-count

Return number of array entries (using explode). The separator is an optional second parameter.

Markup Result
{{#semorg-count:entry1,entry2}} 2
{{#semorg-count:entry1;entry2, including comma|;}} 2

#semorg-query

Get query value (from URL). Use this link to see the effect.

Markup Result
{{#semorg-query:test}}

#semorg-phone

Render phone number in Semantic MediaWiki format. The default country code is set via MediaWiki:Semorg-default-country-code.

Markup Result
{{#semorg-phone:0699/1234567}} +1-699-1234567

#semorg-nocache

Can be used to disable caching on a page.

#semorg-sum

Add amounts and return the sum by leaving out the amount parameter.

Markup Result
{{#semorg-sum:test|5}}{{#semorg-sum:test|10}}{{#semorg-sum:test}} 15

Visualization

#semorg-network

tbd

#semorg-cooperation

tbd

#semorg-circles

tbd