Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

MediaCategories

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

Question

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

Answer

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.

mediacat-2.0.phpΔ

Notes and Comments

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.

Install.

  1. Download the mediacat-2.0.phpΔ file, and put in your cookbook directory.
  2. Add this line to the appropriate config.php file include_once("path/to/cookbook/mediacat-2.0.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.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:

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

$HTMLStylesFmt when categories are marked up by this script.

Notes and Comments

  • This recipe was last tested on PmWiki version: 2.1.5
  • This recipe was first tested on PmWiki version: 2.0beta51
  • This recipe requires at least PmWiki version: The one first introducing the [[!Category]] Markup.

Contributors

History

  • 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.

See Also


Ben Wilson Maintained

Edit - History - Print - Recent Changes - Search
Page last modified on October 10, 2007, at 08:34 PM