[pmwiki-users] foxfilter
noskule
noskule at gmx.net
Sun Apr 6 07:49:32 CDT 2008
hi hans
I'm building a foxfilter to handle categories. It works fine, except if
a user deletes all categories, respectively a empty categories field is
submitted.
the if part of the code below works fine. However if I submit an empty
filed, "no-category" is written into the ptv. But if I change
"no-category" to "" then the filed don't get updated.
What I have to do now to get the ptv cleard. Thanks for any hints.
nos
$FoxFilterFunctions['FoxCategories'] = 'FoxCategoriesFilter';
function FoxCategoriesFilter($pagename, $fields) {
$categories_string = $fields['ptv_Categories'];
$categories_string =
preg_replace("/^[^A-Za-z0-9]*/","",$categories_string);
$categories_string =
preg_replace("/[^A-Za-z0-9]*$/","",$categories_string);
$categories_string =
preg_replace("/[^A-Za-z0-9\s-]*/","",$categories_string);
if ( $categories_string != "" ) {
$categories_arr = explode(" ",$categories_string);
for($i=0;$i<count($categories_arr);$i++) {
$out = $out."[[!".$categories_arr[$i]."]] ";
}
}
else $out = "no-category";
$fields['ptv_Categories'] = $out;
return $fields;
}
More information about the pmwiki-users
mailing list