Help:Excluding a page from an inline query

Semantic extension(s): Semantic MediaWiki · Semantic Extra Special Properties
Further extension(s):  -/-
Keyword(s): selecting pages · page selection · inline queries · pages


Table of Contents

Quering other pages with the same value[edit]

If on a certain page, say page A, you need to create a list of other pages with the same property value(s), it would make good sense to exclude page A from the query.

Below you will three possible solutions. The last two of these assume that you are using templates to handle properties on pages of a certain type.

1. Excluding the current page with Extension:Semantic Extra Special Properties[edit]

Version 1.5.0 and earlier
$sespSpecialProperties[] = '_REVID'; // Add property with current revision ID
Version 2.0 and later
wfLoadExtension( 'SemanticExtraSpecialProperties' );
$sespgEnabledPropertyList[] = '_REVID'; // Add property with current revision ID
  • Run maintenance script "rebuildData.php"Allows to rebuild all the semantic data for a selected data backend/store
  • Add [[Revision ID::!{{REVISIONID}}]] to the query string of the inline query.
NoteNote: This will also hide non existing pages from the result, something that may not be expected.
Since MediaWiki 1.33 this will no longer work if you set configuration parameter $wgMiserMode ( to true.

2. Comparator "!"[edit]

Wildcards and comparators in inline queries can be used only on properties of type 'Text', not on page names. For this reason, the following will not produce the intended results:

{{#ask: {{#arraymap:{{{Property values|}}}|;|x|[[Property A::x]]| OR }} ![[{{PAGENAME}}]]

Instead, create a new property of type 'Text' (Property B in our example) and make sure that it gets its values from the page name. For instance, include the following silent annotation in your template:

 [[Property B::{{PAGENAME}}| ]]
 {{#set: Property B={{PAGENAME}}}}

In this way, you will be able to use the ! parameter for negation:

{{#ask: {{#arraymap:{{{Property values|}}}|;|x|[[Property A::x]]| OR }} [[Property B::!{{PAGENAME}}]]

Similarly, for a Concept

{{#Concept: [[:+]][[Category:Foo]] [[Property B::!Bar]] [[Property B::!Car]] }}

excludes pages with Bar and Car defined for Property B

3. Template[edit]

You can also choose format=template and create a new template in which you exclude the results if the parameter for the page matches PAGENAME. For instance, assuming that the first value in the template corresponds to the name of the page you are using it for:


Note, however, that the default parameter does not work in this case, because the results are filtered out from the query after the query has been performed.

See also[edit]