[Pmwiki-users] can i get a "live" sidebar? / conversion script
Patrick R. Michaud
pmichaud
Fri Oct 15 12:32:44 CDT 2004
On Fri, Oct 15, 2004 at 07:17:40PM +0200, Knut Alboldt wrote:
> I'm using "living sidebars" using "my" recipe
> (http://www.pmwiki.org/wiki/Cookbook/IfGroup) in version 1. This gives the
> possibility to expand / collapse the sidebar according to the group (but
> not within the pagename - yet)
> To implement in v2 this I want to use the new "if"-tag (see my question in
> former mailings) cause it makes more sense to me to use existing functions
> (e.g. [:if $Group=="somegroup":] rather then inventing new (=ifgroup
> somegroup) , but I didn't found out how I can use it (what is the syntax /
> parameters / variables i can use ?).
Yes, documentation on the [:if ... :] syntax is still lagging. Here's
a start:
The [:if ...:] syntax allows portions of the markup text
to be conditionally processed (up to the next [:if:]) depending on
administrator-defined conditions. In 2.0.devel13 the only defined
condition is "false" (which causes the markup text to be ignored,
like a comment), but the admin can define other conditions in the
$Conditions array.
The generic form of the [:if:] directive is
[:if cond param:]
where "cond" names a condition to be tested from the $Conditions array,
and "param" is a parameter or other argument held in $condparm in the
test. For example, the following (in config.php) adds
[:if group GroupName:] as a markup:
$Conditions['group'] = "FmtPageName('\$Group',\$pagename)==\$condparm";
One could then use the following markup:
[:if group PmWiki:] This text only appears in the PmWiki group [:if:]
The negated form of [:if:] is automatically handled as well, thus:
[:if ! group PmWiki:] This text appears everywhere *but* PmWiki [:if:]
Any [:if:] automatically terminates the previous one, thus markup can
be easily cased:
[:if group PmWiki:] Do this in PmWiki group
[:if group Main:] Do something else for Main
[:if:] This happens in all groups
All that remains now is to come up with a good set of $Conditions.
Testing for group membership is a good one, we might also want to
create something for generic pagename pattern matches
[:if match ^PmWiki\. :] Only appears in the PmWikiGroup
[:if match RecentChanges$ :] Everywhere except RecentChanges pages
[:if ! match ^(Main|PmWiki)\. :] All groups except Main and PmWiki
$Conditions could also be conditional on other items; e.g., date or time,
day of week, etc.
> Is there already (or is it planned) a script for complete site-conversion
> we could used after testing, so there's no need to run two wiki.d-dirs ?
It's planned -- just haven't written/published it yet.
Pm
P.S.: Here's a (untested) attempt at the "match" condition
suggested above:
$Condition['match'] = "preg_match('!'.\$condparm.'!',\$pagename)";
Pm
More information about the pmwiki-users
mailing list