[pmwiki-users] Re: Re: variables for customization

chr at home.se chr at home.se
Thu Jul 7 04:21:22 CDT 2005


On Wed, 6 Jul 2005, Patrick R. Michaud wrote:

> On Thu, Jul 07, 2005 at 01:57:54AM +0200, chr at home.se wrote:
> > 
> > What if we introduced some functions such as Group($p = $pagename) and
> > FullName($p = $pagename)  for script authors and administrators to use?
> > Then it is much clearer that we can't assign these arbitrarily, but they
> > are still easily available. They don't have to be variables (in fact, it's 
> > better if they aren't), but it'd be really helpful if this data is easy to 
> > come by.
> 
> I'm afraid I'm not following the proposal exactly.

I see that you read something much more complicated into my proposal than 
what I intended... I'm simply suggesting that pmwiki.php make a function 
available that is called 'Group()'. It should basically work like this:

	$grp = Group();				// Case 1
	$grp = Group("PmWiki.SomePage");	// Case 2

where in the first case Group() should return the name of the group that
current page belongs to, and in the second case Group() should return the
name of group that the page specified by the argument belongs to.

When I wrote Group($p = $pagename) I was trying to illustrate the the 
default argument to Group() should come from $pagename. However, thinking 
about it again, I'm not sure that'll work as simple as that.

> Let me give an example:  In (:pagelist:), the administrator can control
> the output format by setting strings such as
> 
>   $FPLByGroupGFmt = "<dt><a href='\$ScriptUrl/\$Group'>\$Group</a> /</dt>\n";
>   $FPLByGroupIFmt = "<dd><a href='\$PageUrl'>\$Name</a></dd>\n";
> 
> which controls the output for each group and name that is output in
> the list.  The $Group, $PageUrl, and $Name substitutions all change
> for each page in the list.
> 
> Are you proposing that we change this to be
> 
>   $FPLByGroupGFmt = "<dt><a href='\$ScriptUrl/Group()'>Group()</a> /</dt>\n";
>   $FPLByGroupIFmt = "<dd><a href='PageUrl()'>Name()</a></dd>\n";
> 
> instead?

Oh, now I see what you thought I meant. No, definitely not... that'd be 
too confusing... If we did want to change the syntax in the arguments sent 
to FmtPageName, I'd propose some other mechanism such as:

   $FPLByGroupIFmt = "<dd><a href='$(PageUrl)'>$(Name)</a></dd>\n";

which is similar to the $[...] substitions. Or possibly

   $FPLByGroupIFmt = "<dd><a href='%PageUrl%'>%Name%</a></dd>\n";

> We would also need to do this in skin templates and basically
> all other $...Fmt variables where these substitutions are being performed.

To be honest, I'm not sure it'd be worth the effort of changing all the 
strings used by FmtPageName(), not even if we come up with a really good 
syntax. It seems there's just too much risk of breaking stuff for a rather 
small gain. We'd be better of spending this energy on documenting how 
FmtPageName() works instead...

> > > "Placeholder" is fine with me, but they really are markup.
> > 
> > When writing some php code like this
> > 
> > 	$g = FmtPageName("$Group", $pagename)
> > 
> > do you consider '$Group' to be "markup"? To me "markup" refers to what we
> > use when writing wiki pages, so I might get confused.
> 
> In the context of the original statements quoted above, we were (or 
> at least I was) talking specifically about {$Group} as markup and not 
> FmtPageName or PHP variables.

Oh, I see. Well, I definitely agree that it is markup then. 

> > * PHP variables: The good 'ol php variables used by pmwiki.php and 
> >   friends. I'd like to call these 'pmwiki variables', but that'd probably 
> >   be confusing so maybe simply 'php variables' or 'script variables' is 
> >   better?
> 
> I prefer PHP variables.

Ok, then that's settled.  And I think that in general if we just say
"variables", we should be referring to PHP variables. This means we should
make an effort to say something else when we are not referring to PHP
variables.

> > * Markup variables, e.g. "{$Name}" or "{$Group}" that you can write in a
> >   wiki page and have it replaced with something.
> 
> Yes, this is why I think of them as markup and not "variables".  
> "Markup variables" works for me as well.  Jo suggested "placeholder" 
> for these.

ok, now I'm beginning to understand. Hmm... not sure about "placeholder" 
for these. I agree that they're not really variables, but I think the term 
we use for them should emphasize the markup aspect. Perhaps "placeholder 
markup" when being explicit, and just "placeholder" when we want to be 
terse?

OTOH, if we ever introduce some kind of markup that does give us access to 
variables, I can imagine that we might use a syntax like this:

   (:set-var hello=Hello world!:)	(Assigns/creates the variable)
   ...
   ${hello}			   	(Inserts the variable's content)

So then it'd suddenly make sense to talk about ${hello} as a markup 
variable... As for ${Group}, it'd simply be a constant markup variable.

*shesh* I can't decide which term is better, thoughts?

[...]
> Needs to be restated:  
> 
> * Format variables, e.g., "$FullName" and "$PageUrl" that you can
>   give to FmtPageName() and have it interpret the variable for the
>   page name given as the second argument to FmtPageName() (which may
>   have nothing to do with the "current" page as the browser sees it).

Yeah, that's better.

Anyway, I've summarized some of the above here...

	http://www.pmwiki.org/wiki/Test/VariablesAndFriends

Looking at it I really think we should change some of the terminology to 
better suit what it actually does. Calling all of it variables isn't 
really such a great idea...

/C

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr





More information about the pmwiki-users mailing list