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:
The categories are also encapsulated in a div statement (named "category") that allows the site administrator to customize the style for this block.
- Download the mediacat.phpΔ file, and put in your cookbook directory.
- Add this line to the appropriate config.php file
include_once(". It is better to put this line after any redesignation of
$CategoryGroup. This variable is used establish the correct link.
- Use it.
New in Version 2.2.4
$McatShowCategoryLinksAsTitles has been added (can be set in
config.php). If this option is set to
true, then category links in the category block will display as the title of the category page (which may be set, on each
Category/Whatever page, in the usual way, via the
(:title:) directive). Defaults to
false (i.e. the default behavior is the same as before—category links will display just as they appear on the page).
New in Version 2.2
Links of the form
[[!MyCoolCategory]] (with an exclamation point) now also work, in addition to links of the form
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
- 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
$HTMLStylesFmtwhen categories are marked up by this script.
- If this option is set to
true, then category links in the category block will display as the title of the category page. Defaults to
- If this option is set to
true, then category links from included pages are shown on the currently displayed page. Defaults to
false. (Note that this does not cause the current page to be added to those categories.)
- BenWilson v1.0-v2.0
- Said Achmiz v2.1+
- 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.
- October 31, 2017 (version 2.1.1) - Corrected CSS bug (stray semicolon).
- November 30, 2017 (version 2.2) - Updated to allow
- November 30, 2017 (version 2.2.1) - Bug fix.
- December 1, 2017 (version 2.2.2) - by Said Achmiz: The same category link multiple times no longer shows up twice in the category listing block
- December 1, 2017 (version 2.2.3) - by Said Achmiz: A similar category link (differing only by whitespace) multiple times no longer shows up twice; also, an empty category link (containing nothing, or nothing but whitespace) does not show up
- December 6, 2017 (version 2.2.4) - by Said Achmiz: Added $McatShowCategoryLinksAsTitles option
- January 8, 2018 (version 2.2.5) - by Said Achmiz: Added $McatShowCategoriesOnIncludedPages option
See discussion at MediaCategories-Talk
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.