[pmwiki-users] Announcement: Page Variable Extensions recipe
Pico
pmwiki at ben-amotz.com
Thu Jun 29 20:36:45 CDT 2006
Dominique Faure wrote:
> Announcing (officially) the Page Variable Extensions recipe at:
>
> http://www.pmwiki.org/wiki/Cookbook/PageVariableExtensions
>
> This recipe enhances the variable features in several ways, providing
> markup and suffixes functions to dynamically initialize and manipulate
> their values in wiki's pages [snip]
This recipe is *so good* that the announcement did not even mention that
the new variables can be set by url, as in ?set_Var=value, which means
that readers can click on links that will set variables that can be
evaluated by conditional markup to control display and processing of a page.
For example, the first thing I did with this was to provide a link that
adds and removes columns in a table that is generated by pagelist
templates that use table and include directives to gather text from
structured (anchored) pages. Details at the end of this post.
While similar results may have been possible with other recipes (such as
Show Hide) the fact that these page variables can be used by conditional
markup should mean that page rendering can be limited to the selected
set of pagelists and includes (to the exclusion of other sets of
pagelists and includes). That should be a good thing when dealing with
resources, such as pagelists, which can be expensive, and includes,
which are limited (to 50?). Presumably that could make all the
difference when dealing with potentially conflicting markup (for
example, multiple searchresults directives may not play well together
when rendered together on the same page, even in different show hide
divisions, but they should be ok if separated into different conditions,
only one of which is rendered per post).
Again, this is so cool, I just had to share it. In fact, the ability to
use urls to set variables is even downplayed by the recipe: the
documentation mentions it only near the end, and it is not enabled by
default: you have add $EnableUrlSetVar = 1; to the config.php or
farmconfig.php file.
Pico
- - - -
Example
If I have separate pagelist templates called 2column, 3column and 4
column, that use table directives with include directives to populate
each column from structured source pages, then the target page can use a
variation of the following basic markup:
Select view:
[[({$PageUrl}?set_choice=)summary]]
[[({$PageUrl}?set_choice=)normal]]
[[({$PageUrl}?set_choice=)detailed]]
(:if equal {$choice} "summary":)
(:pagelist fmt=#2column:)
(:if equal {$choice} "normal":)
(:pagelist fmt=#3column:)
(:if equal {$choice} "detailed":)
(:pagelist fmt=#4column:)
(:ifend:)
In practice, another condition would be added for the default view:
(:if equal {$choice} "":)
and the links that set the {$choice} variable would be located inside of
the conditions to have them appear to "toggle" (by omitting the self
referencing link from each conditional section)
More information about the pmwiki-users
mailing list