[pmwiki-users] [pmwiki-devel] idea: categories defining properties

Hans design5 at softflow.co.uk
Wed Nov 28 04:51:46 CST 2007


Wednesday, November 28, 2007, 3:28:10 AM, Ben Stallings wrote:

> If I only wanted each page to belong to a single category, I would just
> use my EditDataPages recipe, which allows each page group to have a 
> custom EditForm.  What I'm suggesting is that each page would belong to
> zero or more categories, as Cookbook pages already do:

> Categories: [[!Forms]], [[!Data]]

> and the EditForm would display additional input fields as defined on the
> Category.Forms and Category.Data pages.  Adding more category tags to
> the page would result in more input fields, assuming the categories were
> defined as such.

First, apologies to everyone that my first reply was made to this list
and not pmwiki-devel! Since Ben replied here I will continue too.
Maybe it is of benefit to others as well.

Ben, I think we still would need to use conditional markup on one
edit form to add any extra input fields, according to the presence of
category tags in the page. We cannot really pull together an edit form
from sources in  different pages (as far as I know).

But we could check the page for any relevant tags.

Here is a conditional markup definition, which will check if a string
given is present in the page text. The function strips out any (:...:)
markup, in order not to confuse results too much and to exclude the
string in the markup itself.

First argument is the string to look for, second an optional page name,
so we could use it in other pages.

# add conditional (:if intext 'string':)
# or (:if intext 'string' Group.SomePage:)
$Conditions['intext'] = 'StringInText( $pagename, $condparm )';
function StringInText( $pn, $arg ) {
   $arg = ParseArgs($arg);
   if($arg[''][1]) $pn = MakePageName($pn, $arg[''][1]);
   $page = RetrieveAuthPage($pn, 'read', true);
   $text = preg_replace('/\\(:(.*?):\\)/' ,"", $page['text']);
   if( strpos($text, $arg[''][0])!==false ) return true;
}

Use like (:if intext 'tag1' :) or (:if intext [[!Blog]] SomePage :)
Enclose strings with spaces in quotes.

so on the Editform page you can add:

(:if intext [[!Blog]] {*$FullName}:)...blog controls go here...

or use any other tag syntax.

Would that serve you?

  ~Hans




More information about the pmwiki-users mailing list