[Pmwiki-users] Variables expansion in included files

Patrick R. Michaud pmichaud
Tue Jul 29 09:50:26 CDT 2003


Several of the ...Fmt variables are not in fact global variables but
are created dynamically by FmtPageName depending on the pagename being 
formatted.  These would include $PageUrl, $Group, $Title, $Groupspaced, 
$Titlespaced, and $Title_ (there may be a few others).

However, you can call PmWiki's formatter directly, which will handle
both these special Fmt-variables and global variables as well.  Thus
you can do (borrowing from your example):

 <?php
 	echo FmtPageName("Page last modified \$LastModified (<b><a 
          href='\$PageUrl?action=edit'>Edit</a></b> |
   	  <a href='\$PageUrl?action=diff'>Revisions</a> |
 	  <a href=''>Help</a> |
 	  <a href='\$ScriptUrl/Main/SearchWiki'>Search</a> |
 	  <a href='\$ScriptUrl/Main/AllRecentChanges'>Changes</a>)
 	  <td></tr>",$pagename);
 ?>

and FmtPageName will do the (global+other) substitutions.

Pm

 
On Tue, Jul 29, 2003 at 11:55:52AM +0200, S?bastien Pierre wrote:
> 
> Le lundi, 28 juil 2003, ? 19:44 Europe/Paris, Patrick R. Michaud a 
> ?crit :
> 
> >Because the files are included from within PmWiki's PrintFmt function,
> >you may need to declare embedded variables as global if you want the
> >substitutions to take place:
> >
> >   <div class="small"><?php
> >     global $PageUpdate; echo "Last update $PageUpdate"; ?></div>
> >
> 
> Thanks for the tip (sorry for the $PageUpdate instead of $LastUpdated).
> The $LastUpdated works, but other variables such as $PageUrl and 
> $WikiUrl are expanded into "", while I have the following:
> 
> <?php
> 	global $PageUrl;
> 	global $WikiUrl;
> 	global $LastModified;
> 	echo "Page last modified $LastModified (<b><a 
> href='$PageUrl?action=edit'>Edit</a></b> |
> 	<a href='$PageUrl?action=diff'>Revisions</a> |
> 	<a href=''>Help</a> |
> 	<a href='$WikiUrl/Main/SearchWiki'>Search</a> |
> 	<a href='$WikiUrl/Main/AllRecentChanges'>Changes</a>)
> 	<td></tr>";
> ?>
> 
> Is there something I did wrong ? Or maybe the *Url variables have to be 
> accessed from somewhere else ?
> 
> TIA,
> 
>  -- S?bastien
> 
> --
> ? I do admit that Stackless Python is an ideal environment for
> *something*, but I'm not exactly aware of what this should
> be like, exactly.?
> <http://www.type-z.org>     -- Christian Tismer, stackless creator
> 
> 
> _______________________________________________
> Pmwiki-users mailing list
> Pmwiki-users at pmichaud.com
> http://pmichaud.com/mailman/listinfo/pmwiki-users_pmichaud.com
> 



More information about the pmwiki-users mailing list