Help:Special property Subcategory of

Jump to: navigation, search
Subcategory of
Lets you explicitly indicate that one category is a subcategory of another
Further Information
Provided by: Semantic MediaWiki
Added: 1.5.0
Removed: still in use
Alias: has no alias
Is optional: no
Label: not specified
In this wiki: Property:Subcategory of

The Subcategory of property is a special property in Semantic MediaWiki with a built-in meaning: it is used to indicate that a category is a subcategory of another and that SMW should treat this subcategory as a subclass for the purpose of inferencing in queries. It is primarily useful when $smwgUseCategoryHierarchy is set to false and subcategories need to be explicitly declared - or else ignored - as subclasses.

Setting the special property

Declaring this property is useful only if $smwgUseCategoryHierarchy is set to false. If this configuration setting is set to true (per the default setting), the special property is automatically set on any subcategory[1] and Semantic MediaWiki automatically considers MediaWiki's subcategory hierarchy in querying: for example, if "B" is a subcategory of "A", then a query for all pages within "A" should also return all pages in "B". Subcategories that are found lower in the same hierarchy are also considered in querying, to an extent. See also Help:Inferencing#Subcategories for general information.

If $smwgUseCategoryHierarchy is set to false, however, then pages in subcategories do not automatically turn up in query results. This is where the special property comes in: it lets you explicitly declare subclass relationships for any subcategory, enabling you to specify which subcategories should be considered in querying. This means that a query on a given head category considers pages in those subcategories (including subcategories lower down the hierarchy) where the special property has been manually declared; conversely, it ignores pages in those subcategories where the special property has not been declared.

Example from this site

Querying for a page within the category "Semantic MediaWiki documentation" should also find pages within its subcategories, e.g. "Special properties" and "Configuration parameters", if those categories have the special property [[Subcategory of::Semantic MediaWiki documentation]]. You can query in all subcategories by querying on the head category. For instance,

{{#ask: [[Category:Semantic MediaWiki documentation]] … }}

returns all pages within head category ("Semantic MediaWiki documentation") and its subcategories (e.g. "Special properties" and "Configuration parameters"). Note that other query restrictions still apply when querying within categories.

Note on syntax

On systems where the first letter of an article does not get capitalized make sure that the property is maintained with a capital S [[Subcategory of::Semantic MediaWiki documentation]]; otherwise the system does not recognize it as a special property.

Queries using the special property

The Subcategory of property can be used in a query statement, regardless of the value that is being used for $smwgUseCategoryHierarchy.

Suppose, for instance, that you want to know all subcategories that are the immediate subclasses of "Category:Semantic MediaWiki documentation"; in other words, those that are directly linked to its head category through the special property (which is the case for any subcategory if $smwgUseCategoryHierarchy is set to true). You could, then, construct a query like

{{#ask: [[Subcategory of::Semantic MediaWiki documentation]] }}

(it is not required to use the Category: prefix or to de-link the results)

with the following results:

Category:Configuration parameters (Configuration parameters), Category:Datatypes (Datatypes), Category:Developer documentation (Developer documentation), Category:Parser hooks (Parser hooks), Category:Result formats (Result formats), Category:SMW extensions (SMW extensions), Category:SMW+ extensions (SMW+ extensions), Category:Special properties (Special properties), Functional classes, Installation, Maintenance, Samples, Semantic MediaWiki documentation - old releases, Special pages


Subcategories in deeper levels of the category hierarchy (for instance, those in Category:Developer documentation) are not included in the results. It is not currently possible in SMW to query for subcategories in all levels of the category hierarchy.

See also

See the property page Subcategory of to see which pages use this special property on this wiki.


  1. If the setting is set to true, manually declaring the property will not harm but it serves no purpose.

This documentation page applies to all SMW versions from 1.5.0 to the most current version.

Help:Special property Subcategory of en 1.5.0