Help:Excluding a page from an inline query

Jump to: navigation, search
Semantic extension(s): Semantic MediaWiki · Semantic Extra Special Properties
Further extension(s):  -/-
Keyword(s): selecting pages · page selction


Quering other pages with the same value

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

$sespSpecialProperties[] = '_REVID';// Add property with current revision ID
  • Wait until Special:SMWAdmin is done
  • Add [[Revision ID::!{{REVISIONID}}]] to the query string of the inline query.

This will also hide non existing pages from the result, something that may not be expected.

2. Comparator "!"

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

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