|
Cookbook /
RequireCategorySummary: Require categories to be entered
Version: 2005-09-16
Prerequisites: requires at least PmWiki version: 2.0; last tested on PmWiki version:2.05
Status:
Maintainer:
Categories: Editing, Administration
QuestionI there a way to have requirement for categories? AnswerPut the following code into your config.php file:
## Require Markup
function RequireCategory($pagename, &$page, &$new) {
global $EnablePost, $MessagesFmt;
if (isset($_POST['text']) && strpos(@$new['text'], '[[!') == false) {
$EnablePost = 0;
$MessagesFmt[] = "<h3 class='wikimessage'>The page must contain at
least one category</h3>";
}
}
array_unshift($EditFunctions, 'RequireCategory');
Notes and Comments''The newest the latest. And please don't forget to end by date and name. Thanks) This recipe is nice, but it really needs to exclude a few pages, like 'Site' pages, otherwise you have to put categories on them, which doesn't make any sense at all. However I got it to work by adding this line: && preg_match('/^Site\.|^PMWiki\.|WikiSandbox/', $pagename) == false
That enables Site, PMWiki and Sandbox pages to be exempted from the requirement. -- KathrynAndersen 2006-05-02 the idea is simple, but the only is or not index is [[ if anyone tips this into his text without meaning categories, the system fails ... -- curmetsefrog Versionsdate of publication : 2005-09-16 : RequireCategory - version 00001See AlsoContributorsPM |