Summary: Assembles all Categories in a page, alphabetizes, and appends to bottom of page--in the style similar to MediaWiki.
Version: 2.1
Prerequisites: None
Status: Stable as of 2.1.5
Maintainer: BenWilson


I want a painless way of implementing the Mediawiki markup for categories.


Media Categories simulates the style of the Mediawiki wiki markup. When categories are listed on a line it will label them and put them into a block.



To use this script, simply copy it into the cookbook/ directory and add the following line to config.php (or a per-page/per-groupcustomization file).


Throughout the document, you can place the categories, for example [[!ChickenRecipes]] and [[!Frog Recipes]]. These are pulled from the page, alphabetized, then added at the end of the page. This recipe allows you to set the singular/plural of the category list that is then appended to the end of the page like thus:

Categories: `ChickenRecipies | Frog Recipes

The categories are also encapsulated in a div statement (named "category") that allows the site administrator to customize the style for this block.


  1. Download the mediacat.phpΔ file, and put in your cookbook directory.
  2. Add this line to the appropriate config.php file include_once("path/to/cookbook/mediacat.php");. It is better to put this line after any redesignation of $CategoryGroup. This variable is used establish the correct link.
  3. Use it.

New in Version 2.1

Updated to play well with PmWiki's new built-in category functionality. This recipe now collects only links of the form Category:MyCoolCategory? (a la MediaWiki), and places them in the div.category block at bottom.

New in Version 2.0

My friend Mateusz brought up some good points in a list of notes. In the spirit of friendly competition, I chose to respond by making a better product. Granted, it took me a few months to notice the comments. BenWilson May 07, 2006, at 04:44 PM

  • MediaCategories now pulls free links? using the PmWiki syntax [[!Category Name]], even with spaces.
  • Categories can appear anywhere in the page. After being inventoried, these categories are appended to the end of the page.
  • This version does not rely on spaces, which presented a serious problem in v1.0

Customizable Variables:

This sets the singular form of the category label. Defaults to "Category:"
This sets the plural form of the category label. Defaults to "Categories:"
This determines what the seperator format is. Defaults to ' | '
This creates the markup that creats the block.
This creates the markup that terminates the block.
This is the CSS that is added to

$HTMLStylesFmt when categories are marked up by this script.



  • August 7, 2005 (version 1.0) - Split a list of categories separated by spaces.
  • May 7, 2006 (version 2.0) - Applied different approach to grabbing the categories that did not rely upon spaces.
  • August 15, 2017 (version 2.1) - Updated to work with PmWiki's new built-in category functionality.

See Also


See discussion at MediaCategories-Talk?

Ben Wilson Maintained

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.