[pmwiki-users] Re: Some documentation added for "markup variables" (Was: How to add a variable to {$var}-markup?)
Patrick R. Michaud
pmichaud at pobox.com
Mon Jul 4 11:10:17 CDT 2005
On Mon, Jul 04, 2005 at 09:16:02AM +0200, chr at home.se wrote:
> On Fri, 1 Jul 2005, Patrick R. Michaud wrote:
> > On Tue, Jun 28, 2005 at 10:38:21AM +0200, chr at home.se wrote:
> > > I've added an example of how you can define your own variable -
> > > it'd be good if someone can comment on that bit. For instance, how do you
> > > get the variable to be "dynamically expanded"? I assume this is involves
> > > doing something like:
> > >
> > > $GLOBALS['var'] = '...<magic code invoking ...Fmt()...>';
> >
> > Depends on what you mean by "dynamically expanded" -- do you mean
> > dynamically expanded by markup or by FmtPageName?
>
> I mean using FmtPageName(). So what I'd like is an example of how to
> define the value of a "${variable}" using FmtPageName().
If you mean, how do you define a variable that can be used by FmtPageName
(when it is formatting a string), there are several ways to do it:
1. Set a global variable. FmtPageName() automatically performs
substitution on all global variables that aren't arrays.
If the variable is going to change value over repeated calls
to FmtPageName, it's probably better to use $FmtV in #2 below
instead.
2. Set a value in the $FmtV array. $FmtV['$MyVariable']='something'
means to replace instances of '$MyVariable' with 'something'.
Use this for variables that change value frequently over
multiple calls to FmtPageName.
3. Set a pattern/replacement in the $FmtP array. This is normally
done for substitutions that have to be dynamic somehow based on
the pagename being referenced, such as '$Title', '$Group', '$Name',
'$PageUrl', etc.
But somehow I feel like this isn't the question you were asking...
Pm
More information about the pmwiki-users
mailing list