Rules

Automate MediaWiki page categorization based on rules

Configuration UI of the Rules extension showing regional categories like DACH and Benelux being automatically applied to pages with the right country-level categories

On this page

External links

Rules for MediaWiki

Automate MediaWiki page categorization based on rules defined via a user-friendly configuration interface.

Define rules to categorize pages based on the categories they already contain. Combine conjunctions (AND) and disjunctions (OR) as needed.

For example, place all pages that are in the ISO 27001 category AND in the Policy category AND in the "Doc Status - Final" category into the ISO 27001 category, omitting any policies not yet marked as final. Or create a DACH Customers category with all pages that are in the Customers category AND in at least one of Germany, Austria, OR Switzerland.

Configuration UI of the Rules extension showing automatic categorization of ISO 27001 Policies and Procedures by only including documents in the Policy or Procedure category that are also marked as final

The first version of the extension only supports categorization based on categories. Future versions might contain additional types of conditions and actions.

Professional Wiki created Rules. We are MediaWiki developers that provide professional MediaWiki services.

Usage Documentation

Define rules via the MediaWiki:Rules page. You can find a link to this page on Special:SpecialPages. Only users with the interface-admin right can edit the rules. On standard MediaWiki, users in the sysop group have this right.

Configuration UI of the Rules extension showing automatic categorization to Critical Open Incidents, High-Severity Open Incidents, and Critical Resolved Incidents categories

Edits to rules are visible in the page version history and can thus be audited or reverted.

Automatic categorization does not change the wikitext content of pages and is applied on page save. Regular wiki users thus do not have to do anything. Categories added by rules are removed as soon as their conditions are no longer met.

After defining new rules, you might wish to automatically apply them to all pages. To do this, you must run the refreshLinks.php script. This can only be done with someone who has command-line access to the wiki. Typical command:

php maintenance/run.php refreshLinks

While the rules are shown and edited via a user-friendly user-interface, they are stored in the page as JSON. You can directly edit the JSON at your own risk, which is particularly useful when copying rules between wikis or AI-generating your initial rules based on documentation. The JSON is validated against the Rules JSON Schema.

Installation

Requirements

  • PHP 8.1 or later
  • MediaWiki 1.43 or later

Load and enable

Load the extension using Composer:

COMPOSER=composer.local.json composer require --no-update professional-wiki/rules:~1.0

Enable the extension by adding the following to your LocalSettings.php:

wfLoadExtension( 'Rules' );

You can verify the installation by checking your wiki's Special:Version page.

Configuration

Rules does not have any customizability via PHP configuration.

More MediaWiki Extensions

View all our extensions

Professional MediaWiki Services

MediaWiki services by the authors of Rules

Software Development icon
Software Development

Get superior results from the best MediaWiki developers with a proven track record of creating MediaWiki extensions & integrations.

Theme Development icon
Theme Development

Make your wiki look great! Use a time-tested responsive MediaWiki theme, or have us create a custom MediaWiki skin for you.

MediaWiki Hosting icon
MediaWiki Hosting

Let us take care of your wiki. We are MediaWiki hosting experts and provide cloud hosting, dedicated hosting, and on-premise hosting.

MediaWiki Consulting icon
MediaWiki Consulting

Bring your wiki to the next level by leveraging our MediaWiki expertise. From strategic planning to wikitext, we have you covered.

MediaWiki Migration icon
MediaWiki Migration

Migrate your wiki with confidence. We move your MediaWiki to a new home, or we help you migrate from another system to MediaWiki.

MediaWiki Upgrades icon
MediaWiki Upgrades

Keep your MediaWiki up-to-date and secure. We offer MediaWiki maintenance services to keep your wiki running smoothly.