« 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 safesubst when calling the function.  
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.


If entered on an page, this would substitute the results (writing the information to the page) instead of leaving a dynamic reference.  
==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;&#32;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="&quot;Creation date&quot; 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="&quot;Last editor is&quot; 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;&#32;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;&#32;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;&#32;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="&quot;Creation date&quot; 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="&quot;Last editor is&quot; 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>


<table class="sortable wikitable smwtable"><th>&nbsp;</th><th class="Creation-date"><span class="smw-highlighter" data-type="1" data-state="inline" data-title="Property" title="&quot;Creation date&quot; 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></th><th class="Last-editor-is"><span class="smw-highlighter" data-type="1" data-state="inline" data-title="Property" title="&quot;Last editor is&quot; 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></th><tr data-row-number="1" class="row-odd"><td class="smwtype_wpg">[[::smw-border:|:smw-border:]]</td><td class="Creation-date smwtype_dat"></td><td class="Last-editor-is smwtype_wpg"></td></tr><tr data-row-number="2" class="row-even"><td class="smwtype_wpg">[[:ScientificArticle 1229|"Just a Test, nothing less, nothing more" by Noe, Jane;&#32;Doe, John]]</td><td class="Creation-date smwtype_dat" data-sort-value="2457954.1570949">19 juillet 2017 15:46:13</td><td class="Last-editor-is smwtype_wpg">[[:Utilisateur:HermannSchwaerzler|HermannSchwaerzler]]</td></tr><tr data-row-number="3" class="row-odd"><td class="smwtype_wpg"><span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERY8117187b564363d565b7ae6d29a1a1f0|"Just a Test, nothing less, nothing more" by Noe, Jane;&#32;Doe, John]]</span></td><td class="Creation-date smwtype_dat"></td><td class="Last-editor-is smwtype_wpg"></td></tr><tr data-row-number="4" class="row-even"><td class="smwtype_wpg"><span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERYb313d6eb2929b9c643a123abac6a9e7e|"Just a Test, nothing less, nothing more" by Noe, Jane;&#32;Doe, John]]</span></td><td class="Creation-date smwtype_dat"></td><td class="Last-editor-is smwtype_wpg"></td></tr><tr data-row-number="5" class="row-odd"><td class="smwtype_wpg">[[:ScientificArticle 57639|"Next Test - no mapping property" by Doe, John;&#32;Noe, Jane]]</td><td class="Creation-date smwtype_dat" data-sort-value="2457954.7911806">20 juillet 2017 06:59:18</td><td class="Last-editor-is smwtype_wpg">[[:Utilisateur:HermannSchwaerzler|HermannSchwaerzler]]</td></tr><tr class="smwfooter row-even"><td class="sortbottom" colspan="3"><span class="smw-table-furtherresults">[[:Special:Ask/-5B-5B:+-5D-5D/-3FCreation-20date/-3FLast-20editor-20is/mainlabel=/limit=5/offset=5/format=table|... further results]]</span></td></tr></table>
 
==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;&#32;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;&#32;Doe, John]]</span>
*<span class="smw-subobject-entity">[[:ScientificArticle 1229#_QUERYb313d6eb2929b9c643a123abac6a9e7e|"Just a Test, nothing less, nothing more" by Noe, Jane;&#32;Doe, John]]</span>
*[[:ScientificArticle 57639|"Next Test - no mapping property" by Doe, John;&#32;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

... further results


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

Les cookies nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de cookies.