List Info

Thread: idea: categories defining properties




idea: categories defining properties
country flaguser name
United States
2007-11-27 16:34:23
I have an idea brewing...

I was thinking about http://freebase.com and what
a powerful idea it is,
that any given concept (such as a Wikipedia entry) can
belong to one or
more categories, and that belonging to a category gives the
concept
certain attributes or properties that can be assigned in a
form.  It goes
way beyond the traditional, relational database structure.

And I'm learning Drupal for my new employer, and it has a
very similar
structure, where each page is called a "node" and
belongs to categories,
and the way the page is displayed depends on the categories
it belongs to.

And I was thinking, hey, PmWiki pages can belong to one or
more
categories, and they can have page-text variables assigned
by a form, and
those properties can be displayed in various templates.  The
only thing
that's missing is the mechanism to define the properties of
each category,
and to display the proper form inputs when editing a page
depending on the
categories it belongs to.

The way I see it, we're already most of the way there... the
necessary
elements are

* A user-friendly way to assign pages to categories. 
Freebase uses an
AJAX-powered combo box, but we could go lower-tech with a
select-multiple
and a text input.

* Conditional markup to test what categories the page
currently belongs to
 (Does this already exist?)

* A new recipe to customize EditForm and SiteHeader to
display the
appropriate form fields and templates.

Does the idea have merit?  Are we closer than I think, or
farther?

Of course, assigning properties to pages is only part of the
puzzle; The
real power of Freebase is its query language (MJT).  But one
thing at a
time.  --Ben S.


_______________________________________________
pmwiki-devel mailing list
pmwiki-develpmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Re: idea: categories defining properties
country flaguser name
United Kingdom
2007-11-29 08:21:57
Tuesday, November 27, 2007, 10:34:23 PM, ben wrote:

> * A user-friendly way to assign pages to categories. 
Freebase uses an
> AJAX-powered combo box, but we could go lower-tech with
a select-multiple
> and a text input.

In PmWiki a 'category' is just a page in a group 'Category'
(and it
does not need to exist even), and we are using a custom link
in the
page text to link to this category page [[!SomeCategory]].
then the
link= paramete rin pagelist can display all pages which ar
elinke dto
a category(page). So categories are not page attributes.

If you talk about multiple select boxes for assigning
categories the
question spring to my mind: how are the categories added to
the page
text? We would need to insert links to the category pages.
Or are you
suggesting that categories should become page attributes, or
a page
attribute, like 'text', 'csum', 'author'? Then a custom
field on an
edit form can write the custom attribute, like a list of
categories.

> * Conditional markup to test what categories the page
currently belongs to
>  (Does this already exist?)

This is connected with the above: if categories are links in
the page
text we could extract them with  a markup expression. If
categories
are page attributes we can also extract them with  a
different markup
expression, or better as a page variable. The list of
categories in
form of a list of comma-separated page names we can use in a
pagelist.

> * A new recipe to customize EditForm and SiteHeader to
display the
> appropriate form fields and templates.

A general custom EditForm can be built which can show input
controls
according to which categories the page is connected to. It
can use a
pagelist to add input form elements for instance from each
category
page the page is connected to.

I just tested the last and it works fine. I also wrote a
markup
expression which extracts category links from  a page, and
this works
fine within the pagelist employed in the edit form. I am not
sure what
the custom controls from category pages should do, but the
potential
is there to write any custom page attributes, which will
make the page
more like  a data base record, or to employ some form
processing script
and write page text variables or whatever into the page
text.

And there is also the editform=PAGENAME parameter, which one
could
add to ?action=edit and load a custom edit form on edit.

Here is a markup expression for extracting a category list:

# {(catlist PAGENAME)} extracts a list of full pagenames
# of all category links on a page
$MarkupExpr['catlist'] = 'CategoryList($pagename,
$args[0])';
function CategoryList($pn, $arg='') {
        global $CategoryGroup;
        if($arg) $pn = MakePageName($pn, $arg);
        $page = RetrieveAuthPage($pn, 'read', true);
        $pat = '/\[\[\!(.*?)\]\]/';
        if(preg_match_all($pat, $page['text'], $matches)) {
        foreach($matches[1] as $i=>$m)
                $matches[1][$i] =
$CategoryGroup.".".$m;
        return implode(",", $matches[1]);
        }
}

Here is a pagelist directive for use in a custom edit form:

(:pagelist name={(catlist {*$FullName})} fmt=#catform 

and here is the #catform pagelist template, which will load
any
category specific edit form elements, from the category
page's
#editform section:

[
[[#catform]]
(:include Category.{=$Name}#editform 
[[#catformend]]
]


Hans


_______________________________________________
pmwiki-devel mailing list
pmwiki-develpmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )