[pmwiki-users] Categories in a own textfield
Patrick R. Michaud
pmichaud at pobox.com
Fri Sep 16 07:35:36 CDT 2005
On Fri, Sep 16, 2005 at 02:09:14PM +0200, nexyufuli evo wrote:
> Patrick R. Michaud schrieb:
> >On Fri, Sep 16, 2005 at 12:02:48PM +0200, nexyufuli evo wrote:
> >
> >>I would like to use a sparate textfield for editting the category names.
> >>Cause for one project it is nessesary that every page has categories.
> >>So, if the textfield is emty, i can make a errormessage.
> >
> >Instead of creating a separate textfield for this, we could write
> >an edit filter that requires at least one category be present in
> >the markup, otherwise it doesn't save the page and returns back
> >to the edit form with an error message.
> >Would that work?
> >
> yep, this would be cool to.
Here's code to require a page to have at least one category in it
(it actually looks for "[[!") before the page can be saved:
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');
You can see this work at http://www.pmwiki.org/wiki/Test/CategoryRequired .
Pm
More information about the pmwiki-users
mailing list