[pmwiki-users] New recipe: PTVInclude
Patrick R. Michaud
pmichaud at pobox.com
Tue Apr 17 09:45:35 CDT 2007
On Tue, Apr 17, 2007 at 03:21:15PM +0100, Hans wrote:
> Tuesday, April 17, 2007, 2:45:17 PM, Patrick wrote:
>
> > If basepage= is provided, then all
> > relative links and page variables are interpreted relative
> > to basepage.
>
> Is this the main purpose of the basepage= parameter?
> So basepage can act as a kind of data page and reference page for
> relative links?
Somewhat. Its primary purpose is to allow one to include pages
in a way that mimics the 2.1.x behavior where page variables
and links are interpreted relative to the currently displayed page.
This is done with:
(:include SomeOtherPage basepage='' :)
-or-
(:include SomeOtherPage basepage={*$FullName} :)
It also allows GroupHeader and GroupFooter to have their page
variables and links be relative to the currently displayed page
(instead of GroupHeader and GroupFooter):
## PmWiki default $GroupHeaderFmt setting
$GroupHeaderFmt =
'(:include {$Group}.GroupHeader self=0 basepage={*$FullName}:)(:nl:)';
Otherwise, using {$Name} inside of a GroupHeader would display
'GroupHeader' and not the name of the currently displayed page.
But as we've discovered today, the basepage= parameter is general
enough that it can also be used as a templating engine, so that
we can grab a template page containing variables that are then
filled in with values from another page:
(:include TemplatePage basepage=DataPage :)
And, of course, a single TemplatePage can actually contain multiple
templates delimited by anchors, so that we end up with a syntax
eerily similar[1] to pagelist-templates:
(:include TemplatePage#abc basepage=DataPage :)
(:include TemplatePage#def basepage=DataPage :)
(:include TemplatePage#xyz basepage=DataPage :)
So then TemplatePage can use a syntax like:
[@
[[#abc]]
...template stuff here...
[[#abcend]]
@]
and it's possible to display TemplatePage as a template
without it being interpreted... same as we do for
Site.PageListTemplates .
Cool.
Pm
[1] Okay, maybe it's not so eerie, given that the pagelist template
code actually uses the same function as (:include:) to grab its
templates. But it's still a useful parallel. :-)
More information about the pmwiki-users
mailing list