[pmwiki-users] pmwiki-2.2.0-beta9 release (bugfix, pagevar filters in pagelists)

Patrick R. Michaud pmichaud at pobox.com
Mon Oct 2 12:43:04 CDT 2006


On Mon, Oct 02, 2006 at 11:32:27AM -0400, Crisses wrote:
>    ----
>    !!Simile search page titles for "mice"
>    (:pagelist group=Simile $Title=*mice*:)
>    Only the natural PmWiki search (the third one) works.  I didn't expect the
>    other two to yet, but it was worth looking to see.
>    So, Caveman -- I'm going to need the translation from the current FASTData
>    data page to a PmWiki natural page.  (from Work="Of Mice and Men" to
>    Work:Of Mice and Men )
>    PM -- I'm also going to need some way to look at the data in one group and
>    return the corresponding page in another group:
>    Very important -- for compatibility with storing data on other pages,
>    which many recipes may be using.  there may be a way to do this with a
>    custom #fmt but I haven't figured it out yet :/

This is now possible in 2.2.0-beta10 (just released), using
the new {$BaseName} page variable markup.

Essentially, an administrator or recipe uses $BaseNamePatterns
to define transformations from a pagename into its "base" form.
For example, a comments recipe might define:

    $BaseNamePatterns['/-Talk$/'] = '';

which says that the "base name" of any page ending in "-Talk" is
the name without the "-Talk".  Thus for any page, one can use 
{$BaseName} to obtain:

    The page without the -Talk extension:    {$BaseName}
    The page with the -Talk extension:       {$BaseName}-Talk

In Crisses' specific example of "Simile.*" and "Data-Simile.*",
define:

    $BaseNamePatterns['/^Data-/'] = '';

Then, for any page, one can get the "Data-" or non-"Data-"
version of a pagename by using either:

    Page without the Data- prefix:      {$BaseName}
    Page with the Data- prefix:         Data-{$BaseName}

For a pagelist command, to search the Data-Simile group
one would use

    (:pagelist $:Work=*mice* group=Data-Simile :)

and then in the pagelist template to refer to the non-Data
group regardless of source one would use things like:

    {=$BaseName}           "Simile.XYZ"
    {{=$BaseName}$Group}   "Simile"

Or, to always get the Data- group regardless of source, one would use:

    Data-{=$BaseName}           "Data-Simile.XYZ"
    Data-{{=$BaseName}$Group}   "Data-Simile"

>    Less important:
>    Return the list, group by authors (list only one per author), point to the
>    category pages "Author_AuthorsName".
>    ...
>    Also is there a way to group the responses by a data field?  Or have it
>    list a unique datafield?

Sure, one can group responses by data field with:

    (:pagelist order=$:Author:)

and then in a pagelist template:

    (:if ! equal {=$:Author} {<$:Author}:)Author: {=$:Author} (:if:)
    * {=$FullName}

So far I'm still thinking about ways to group by partial field values
(e.g., first letter of author name) or to provide group orderings 
other than alphanumeric.  So far the best way to do partial field values
is with a custom page variable.  (E.g., a custom "$Author_1" page 
variable to return the first letter of the author name.)

But I'm not sure how much more pagelist stuff will go into the core;
it's starting to feel a bit overdone.  We'll see.

Pm




More information about the pmwiki-users mailing list