[pmwiki-users] Page file formats

Patrick R. Michaud pmichaud at pobox.com
Thu Aug 24 11:30:17 CDT 2006


On Thu, Aug 24, 2006 at 10:28:18AM -0400, The Editor wrote:
> Here are a couple quick questions I have after examining the
> documentation (PmWiki/FageFileFormat).
> 
> 1)  How does one use page variables in recipes.  For example I'm wanting to set
> 
>       version={$version} ordered=1 urlencoded=1

Use the FmtPageName() function, or the PageVar() function.


> 2)  Can you manually set the title right in the page headers without
> having to use a title directive, ie have a line that looks like:  (I'm
> wanting this retrievable as {$Title} in pagelists.
> 
>        title=My New Page

I think this will work, but I can't be certain.  I do know that
title handling may change in a short-term release, so I can't
guarantee that the way it works now will be the same in the future.
However, I'm pretty sure that I'll end up with {$Title} always
exclusively using the title= attribute in the page.

> 3)  Is there anyway to override PmWiki's rewriting of the author
> header whenever a page is  edited by an entry in a group config file.
> My thought was this could be used to preserve the original author's
> name, rather than the latest modifier of the page.  Albeit, it would
> presumably be retrieved by {$LastModifiedBy}.  :)  Optionally, of
> course, could another line be added called Creator (or a bit less
> imposing--CreatedBy).

As part of my blogging/comment recipes, I'm working on a way to
update pages without completely rewriting all of the automatic
attributes, yes.

> 4) In setting the ctime and time lines, I presume you would use the
> time() function in php to get the right time stamp, and these are then
> used to sort in a pagelist.  But how does one retrieve those times in
> pagelist display, as in page created time, or page last modified time.
>  {$LastModified} I presume returns time.  But there is no page
> variable for  ctime, such as {$DataCreated}.  

See the bottom of http://www.pmwiki.org/wiki/PmWiki/PageVariables
for an example (in fact, the example uses ctime).

> 5) How do you retrieve the page creator's "host" ip address in a
> recipe function?  

The page variable {$LastModifiedHost} returns the ip address.
Or, use the 'host' page attribute for a page.

> 6) There does not seem to be any indication of the order of parameters
> in the Pmwiki/PageFileFormat documentation.  Can title and time come
> before text?  Or do they have to follow it, in some specified order.

If the first line contains "ordered=1", then PmWiki expects the attributes
to be in a specific order (alphabetic first, followed by the page history
in reverse-time sequence).  If the first line doesn't contain "ordered=1",
then the attributes can be in any sequence.

> 7) The docs say that in the text string, newlines must be converted to
> %0a and %'s to %25.  Is there a pmwiki function that automatically
> does that?  It seems using urlencode() would change far more than is
> desired.  

I simply use

      $r0 = array('%', "\n", '<');
      $r1 = array('%25', '%0a', '%3c');
      $x = str_replace($r0, $r1, $x);

It's only used in one place (when writing page files) so it hasn't
been worth creating a separate function for it.

BTW, FWIW, I highly recommend re-using PmWiki's existing WritePage()
function as opposed to creating a separate, duplicate version.
If there are minor changes that you need to have added, we can see
about doing this.

> A good pmwiki function would be nice because I've noticed a
> couple other things don't work right.  For example a ' is returned as
> \'

It's probably the /e modifier in preg_replace that is converting
' into \'.  Or, PHP will automatically convert quotes in forms to have
a backslash in front of them if the PHP configuration variable 
"get_magic_quotes_gpc" is set.  PmWiki offers the stripslashes()
function to remove any backslashes added by PHP's magic quotes,
and the PSS() function to remove any backslashes added by the /e 
option to preg_replace.  PmWiki itself never adds backslashes
on its own.

Pm




More information about the pmwiki-users mailing list