« Take Snapshot » : différence entre les versions
De Semantic MediaWiki - Sandbox
(created) |
(keep the links) |
||
(4 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
To take a 'snapshot' of the results of an ask query, use | To take a 'snapshot' of the results of an ask query, you can use [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Substitution parser function substitution.] | ||
For example: | For example, the following statement: | ||
<nowiki>{{safesubst:#ask: [[:+]] | <nowiki>{{safesubst:#ask: [[:+]] | ||
|?Creation date | |?Creation date | ||
|?Last editor is | |?Last editor is | ||
|limit=5 | |limit=5 | ||
|format=ul | |||
}}</nowiki> | }}</nowiki> | ||
If entered on an page, would ''substitute'' the results/output (writing the information to the page) instead of leaving an in-line query behind. | |||
==Output== | |||
<ul class="smw-format ul-format "><li class="smw-row"><span class="smw-field"><span class="smw-value">[[::smw-border:|:smw-border:]]</span></span></li><li class="smw-row"><span class="smw-field"><span class="smw-value">[[:ScientificArticle 1229|"Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John]]</span></span> (<span class="smw-field"><span class="smw-field-label"><span class="smw-highlighter" data-type="1" data-state="inline" data-title="Property" title=""Creation date" is a predefined property that corresponds to the date of the first revision of a subject and is provided by Semantic MediaWiki."><span class="smwbuiltin">[[:Attribut:Creation date|Creation date]]</span><span class="smwttcontent">"Creation date" is a predefined property that corresponds to the date of the first revision of a subject and is provided by [https://www.semantic-mediawiki.org/wiki/Help:Special_properties Semantic MediaWiki].</span></span></span>: <span class="smw-value">19 juillet 2017 15:46:13</span></span>, <span class="smw-field"><span class="smw-field-label"><span class="smw-highlighter" data-type="1" data-state="inline" data-title="Property" title=""Last editor is" is a predefined property that contains the page name of the user who created the last revision and is provided by Semantic MediaWiki."><span class="smwbuiltin">[[:Attribut:Last editor is|Last editor is]]</span><span class="smwttcontent">"Last editor is" is a predefined property that contains the page name of the user who created the last revision and is provided by [https://www.semantic-mediawiki.org/wiki/Help:Special_properties Semantic MediaWiki].</span></span></span>: <span class="smw-value">[[:Utilisateur:HermannSchwaerzler|HermannSchwaerzler]]</span></span>)</li><li class="smw-row"><span class="smw-field"><span class="smw-value"><span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERY8117187b564363d565b7ae6d29a1a1f0|"Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John]]</span></span></span></li><li class="smw-row"><span class="smw-field"><span class="smw-value"><span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERYb313d6eb2929b9c643a123abac6a9e7e|"Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John]]</span></span></span></li><li class="smw-row"><span class="smw-field"><span class="smw-value">[[:ScientificArticle 57639|"Next Test - no mapping property" by Doe, John; Noe, Jane]]</span></span> (<span class="smw-field"><span class="smw-field-label"><span class="smw-highlighter" data-type="1" data-state="inline" data-title="Property" title=""Creation date" is a predefined property that corresponds to the date of the first revision of a subject and is provided by Semantic MediaWiki."><span class="smwbuiltin">[[:Attribut:Creation date|Creation date]]</span><span class="smwttcontent">"Creation date" is a predefined property that corresponds to the date of the first revision of a subject and is provided by [https://www.semantic-mediawiki.org/wiki/Help:Special_properties Semantic MediaWiki].</span></span></span>: <span class="smw-value">20 juillet 2017 06:59:18</span></span>, <span class="smw-field"><span class="smw-field-label"><span class="smw-highlighter" data-type="1" data-state="inline" data-title="Property" title=""Last editor is" is a predefined property that contains the page name of the user who created the last revision and is provided by Semantic MediaWiki."><span class="smwbuiltin">[[:Attribut:Last editor is|Last editor is]]</span><span class="smwttcontent">"Last editor is" is a predefined property that contains the page name of the user who created the last revision and is provided by [https://www.semantic-mediawiki.org/wiki/Help:Special_properties Semantic MediaWiki].</span></span></span>: <span class="smw-value">[[:Utilisateur:HermannSchwaerzler|HermannSchwaerzler]]</span></span>)</li></ul><span class="smw-ul-furtherresults">[[:Special:Ask/-5B-5B:+-5D-5D/-3FCreation-20date/-3FLast-20editor-20is/mainlabel=/limit=5/offset=5/format=ul|... further results]]</span> | |||
==Formatting== | |||
Notice the output is very raw (not the clean wiki-markup you might have been expecting). To get around this, you can use the template format which will give you [https://www.mediawiki.org/wiki/Help:Substitution additional control over what is being substituted] (not to mention, control over how 'deep' of a substitution you want to do). | |||
<nowiki>{{safesubst:#ask: [[:+]] | |||
|?Creation date | |||
|?Last editor is | |||
|limit=5 | |||
|format=template | |||
|template=safesubst:Snapshot | |||
}}</nowiki> | |||
==Template Output== | |||
[[SMW::off]] | |||
*[[::smw-border:|:smw-border:]] | |||
*[[:ScientificArticle 1229|"Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John]]19 juillet 2017 15:46:13[[:Utilisateur:HermannSchwaerzler|HermannSchwaerzler]] | |||
*<span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERY8117187b564363d565b7ae6d29a1a1f0|"Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John]]</span> | |||
*<span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERYb313d6eb2929b9c643a123abac6a9e7e|"Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John]]</span> | |||
*[[:ScientificArticle 57639|"Next Test - no mapping property" by Doe, John; Noe, Jane]]20 juillet 2017 06:59:18[[:Utilisateur:HermannSchwaerzler|HermannSchwaerzler]]<span class="smw-template-furtherresults">[[:Special:Ask/-5B-5B:+-5D-5D/-3FCreation-20date/-3FLast-20editor-20is/mainlabel=/limit=5/offset=5/format=template/template=safesubst:Snapshot|... further results]]</span>[[SMW::on]] |
Dernière version du 8 août 2019 à 20:51
To take a 'snapshot' of the results of an ask query, you can use parser function substitution.
For example, the following statement:
{{safesubst:#ask: [[:+]] |?Creation date |?Last editor is |limit=5 |format=ul }}
If entered on an page, would substitute the results/output (writing the information to the page) instead of leaving an in-line query behind.
Output
- [[::smw-border:|:smw-border:]]
- "Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John (Creation date"Creation date" is a predefined property that corresponds to the date of the first revision of a subject and is provided by Semantic MediaWiki.: 19 juillet 2017 15:46:13, Last editor is"Last editor is" is a predefined property that contains the page name of the user who created the last revision and is provided by Semantic MediaWiki.: HermannSchwaerzler)
- "Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John
- "Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John
- "Next Test - no mapping property" by Doe, John; Noe, Jane (Creation date"Creation date" is a predefined property that corresponds to the date of the first revision of a subject and is provided by Semantic MediaWiki.: 20 juillet 2017 06:59:18, Last editor is"Last editor is" is a predefined property that contains the page name of the user who created the last revision and is provided by Semantic MediaWiki.: HermannSchwaerzler)
Formatting
Notice the output is very raw (not the clean wiki-markup you might have been expecting). To get around this, you can use the template format which will give you additional control over what is being substituted (not to mention, control over how 'deep' of a substitution you want to do).
{{safesubst:#ask: [[:+]] |?Creation date |?Last editor is |limit=5 |format=template |template=safesubst:Snapshot }}
Template Output
- [[::smw-border:|:smw-border:]]
- "Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John19 juillet 2017 15:46:13HermannSchwaerzler
- "Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John
- "Just a Test, nothing less, nothing more" by Noe, Jane; Doe, John
- "Next Test - no mapping property" by Doe, John; Noe, Jane20 juillet 2017 06:59:18HermannSchwaerzler... further results