Difference between revisions of "Paging Plugin"
(→Syntax) |
|||
(33 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | This is a special interaction plugin that allows you to integrate paging into templated content items (i.e. a [[Content Root Object]] that uses the <code>template</code> and <code>items</code> properties). The plugin can be used with version '''0.1.82''' or higher. | + | This is a special interaction plugin that allows you to integrate paging into templated content items (i.e. a [[Content Root Object]] that uses the <code>template</code> and <code>items</code> properties). In order to use this plugin, a corresponding content service must be implemented that processes the requested items (i.e. by evaluating the <code>offset</code> and <code>limit</code> parameters). The plugin can be used with version '''0.1.82''' or higher. |
== Usage == | == Usage == | ||
− | The plugin must be loaded with a content URL. Optionally, the limit can be indicated (by default, | + | The plugin must be loaded with a content service URL that is able to evaluate the <code>offset</code> and <code>limit</code> parameters. Optionally, the requested limit can be indicated (by default, it is set to <code>20</code>). Please see following action syntax examples. |
* <code>content:request:interaction:{URL}@http://msx.benzac.de/interaction/paging.html</code> | * <code>content:request:interaction:{URL}@http://msx.benzac.de/interaction/paging.html</code> | ||
* <code>content:request:interaction:{URL}|{LIMIT}@http://msx.benzac.de/interaction/paging.html</code> | * <code>content:request:interaction:{URL}|{LIMIT}@http://msx.benzac.de/interaction/paging.html</code> | ||
− | The content URL should contain the keywords <code>{OFFSET}</code> and <code>{LIMIT}</code>, which are replaced with the corresponding values. Please see following action syntax examples. | + | The content service URL should contain the keywords <code>{OFFSET}</code> and <code>{LIMIT}</code>, which are replaced with the corresponding values. Please see following action syntax examples. |
− | * <code>content:request:interaction:http://link.to.content?offset={OFFSET}&limit={LIMIT}@http://msx.benzac.de/interaction/paging.html</code> | + | * <code>content:request:interaction:http<span>://</span>link.to.content?offset={OFFSET}&limit={LIMIT}@http://msx.benzac.de/interaction/paging.html</code> |
− | * <code>content:request:interaction:http://link.to.content?offset={OFFSET}&limit={LIMIT}{{ | + | * <code>content:request:interaction:http<span>://</span>link.to.content?offset={OFFSET}&limit={LIMIT}|40@http://msx.benzac.de/interaction/paging.html</code> |
+ | |||
+ | If you would like to use the plugin as reference to implement your own plugin, please have a look at this implementation script: http://msx.benzac.de/interaction/js/paging.js. | ||
+ | |||
+ | '''Note: Currently, the paging plugin cannot be used with panels.''' | ||
+ | |||
+ | == Syntax == | ||
+ | {| class="wikitable sortable" | ||
+ | |+ Parameter syntax of content service for paging plugin | ||
+ | |- | ||
+ | ! Keyword !! Parameter !! Type !! Default Value !! Mandatory !! class="unsortable" | Description | ||
+ | |- | ||
+ | | <code>{ID}</code> || <code>id</code> || <code>string</code> || <code>null</code> || No || | ||
+ | An automatically generated unique device ID. | ||
+ | |- | ||
+ | | <code>{OFFSET}</code> || <code>offset</code> || <code>number</code> || <code>0</code> || '''Yes''' || | ||
+ | The offset that specifies from which offset the items should start. | ||
+ | |||
+ | '''Note: The initial request from the paging plugin will always have the offset <code>0</code>. If an offset greater than <code>0</code> is requested, the content service only needs to return the <code>items</code> property, because the other properties are inherited from the initial request.''' | ||
+ | |- | ||
+ | | <code>{LIMIT}</code> || <code>limit</code> || <code>number</code> || <code>20</code> || '''Yes''' || | ||
+ | The limit that specifies how many items should be returned. | ||
+ | |||
+ | '''Note: If the content service returns less or more items then indicated, no additional items will be requested.''' | ||
+ | |- | ||
+ | | <code>credentials</code> || <code>credentials</code> || <code>void</code> || n/a || No || | ||
+ | A keyword that indicates that user credentials (e.g. cookies, authorization headers, etc.) are enabled for content service requests. Technically, this keyword sets the <code>withCredentials</code> flag for the <code>XMLHttpRequest</code> object to <code>true</code>. If the content service uses HTTP sessions and manages them via cookies, you should add this keyword. | ||
+ | |} | ||
+ | '''Note: The parameter column shows the recommended parameter names. Generally, each keyword can be set to any parameter name or integrated into the path of the content service URL.''' | ||
+ | |||
+ | == Example == | ||
+ | === Screenshot === | ||
+ | [[File:paging_plugin.png|thumb|640px|none|Example Screenshot (Paging Plugin)]] | ||
+ | |||
+ | === Code === | ||
+ | <syntaxhighlight lang="json"> | ||
+ | { | ||
+ | "headline": "Paging Examples", | ||
+ | "menu": [{ | ||
+ | "label": "Paging Example 1", | ||
+ | "extensionLabel": "Limit: 20", | ||
+ | "data": "request:interaction:http://msx.benzac.de/services/paging.php?offset={OFFSET}&limit={LIMIT}|20@http://msx.benzac.de/interaction/paging.html" | ||
+ | }, { | ||
+ | "label": "Paging Example 2", | ||
+ | "extensionLabel": "Limit: 30", | ||
+ | "data": "request:interaction:http://msx.benzac.de/services/paging.php?offset={OFFSET}&limit={LIMIT}|30@http://msx.benzac.de/interaction/paging.html" | ||
+ | }, { | ||
+ | "label": "Paging Example 3", | ||
+ | "extensionLabel": "Limit: 40", | ||
+ | "data": "request:interaction:http://msx.benzac.de/services/paging.php?offset={OFFSET}&limit={LIMIT}|40@http://msx.benzac.de/interaction/paging.html" | ||
+ | }] | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Demo === | ||
+ | * Launch via App: https://msx.benzac.de/?start=menu:https://msx.benzac.de/info/xp/data/plugin_test_12.json | ||
+ | * Launch via Demo Page: https://msx.benzac.de/info/?start=menu:https://msx.benzac.de/info/xp/data/plugin_test_12.json | ||
+ | |||
+ | == See also == | ||
+ | * [[Interaction Plugin]] | ||
+ | * [[Plugin API Reference]] |
Latest revision as of 12:05, 17 March 2024
This is a special interaction plugin that allows you to integrate paging into templated content items (i.e. a Content Root Object that uses the template
and items
properties). In order to use this plugin, a corresponding content service must be implemented that processes the requested items (i.e. by evaluating the offset
and limit
parameters). The plugin can be used with version 0.1.82 or higher.
Usage[edit]
The plugin must be loaded with a content service URL that is able to evaluate the offset
and limit
parameters. Optionally, the requested limit can be indicated (by default, it is set to 20
). Please see following action syntax examples.
content:request:interaction:{URL}@http://msx.benzac.de/interaction/paging.html
content:request:interaction:{URL}|{LIMIT}@http://msx.benzac.de/interaction/paging.html
The content service URL should contain the keywords {OFFSET}
and {LIMIT}
, which are replaced with the corresponding values. Please see following action syntax examples.
content:request:interaction:http://link.to.content?offset={OFFSET}&limit={LIMIT}@http://msx.benzac.de/interaction/paging.html
content:request:interaction:http://link.to.content?offset={OFFSET}&limit={LIMIT}|40@http://msx.benzac.de/interaction/paging.html
If you would like to use the plugin as reference to implement your own plugin, please have a look at this implementation script: http://msx.benzac.de/interaction/js/paging.js.
Note: Currently, the paging plugin cannot be used with panels.
Syntax[edit]
Keyword | Parameter | Type | Default Value | Mandatory | Description |
---|---|---|---|---|---|
{ID} |
id |
string |
null |
No |
An automatically generated unique device ID. |
{OFFSET} |
offset |
number |
0 |
Yes |
The offset that specifies from which offset the items should start. Note: The initial request from the paging plugin will always have the offset |
{LIMIT} |
limit |
number |
20 |
Yes |
The limit that specifies how many items should be returned. Note: If the content service returns less or more items then indicated, no additional items will be requested. |
credentials |
credentials |
void |
n/a | No |
A keyword that indicates that user credentials (e.g. cookies, authorization headers, etc.) are enabled for content service requests. Technically, this keyword sets the |
Note: The parameter column shows the recommended parameter names. Generally, each keyword can be set to any parameter name or integrated into the path of the content service URL.
Example[edit]
Screenshot[edit]
Code[edit]
{
"headline": "Paging Examples",
"menu": [{
"label": "Paging Example 1",
"extensionLabel": "Limit: 20",
"data": "request:interaction:http://msx.benzac.de/services/paging.php?offset={OFFSET}&limit={LIMIT}|20@http://msx.benzac.de/interaction/paging.html"
}, {
"label": "Paging Example 2",
"extensionLabel": "Limit: 30",
"data": "request:interaction:http://msx.benzac.de/services/paging.php?offset={OFFSET}&limit={LIMIT}|30@http://msx.benzac.de/interaction/paging.html"
}, {
"label": "Paging Example 3",
"extensionLabel": "Limit: 40",
"data": "request:interaction:http://msx.benzac.de/services/paging.php?offset={OFFSET}&limit={LIMIT}|40@http://msx.benzac.de/interaction/paging.html"
}]
}
Demo[edit]
- Launch via App: https://msx.benzac.de/?start=menu:https://msx.benzac.de/info/xp/data/plugin_test_12.json
- Launch via Demo Page: https://msx.benzac.de/info/?start=menu:https://msx.benzac.de/info/xp/data/plugin_test_12.json