[Pmwiki-users] Change logo to replacement HTML?

Patrick R. Michaud pmichaud
Wed Feb 25 07:51:12 CST 2004


On Tue, Feb 24, 2004 at 11:09:53AM -0500, J. Perkins wrote:
> 
> A comment about the wiki logo: some of the sites I have set up don't use 
> an image, but rather a snippet of HTML for the logo. Working off the 
> default PmWiki skin, this requires me to create a whole new template 
> with the <img> tag replaced, rather than simply replacing a value in 
> config.php. Would it be possible to introduce a couple of new variables?
> 
> $PageLogoHref = $ScriptUrl;
> $PageLogoFmt = "<a href='$PageLogoHref'><img src='$PageLogoUrl' 
> border='0' alt='$WikiTitle' /></a>";

Almost.  I'd probably get rid of the $PageLogoHref definition, and just
go with $PageLogoFmt:

$PageLogoFmt = "<a href='\$ScriptUrl'><img src='\$PageLogoUrl' 
border='0' alt='\$WikiTitle' /></a>";

Note that the '$'s should be escaped to be able to handle local
customizations of $ScriptUrl, $PageLogoUrl, and $WikiTitle in config.php.

But one of the issues with the current template code is that putting 
a $...Fmt variable into the template often won't work, because the 
substitutions take place in a sequence.  The current sequence of 
FmtPageName is:
  1. perform $[...] translations for internationalization
  2. fix URLs when $EnablePathInfo==0:
     2a.  Substitute $PageUrl and $PageName.
     2b.  Convert strings of the form '$ScriptUrl/$Group/$Title?query'
          to the form '$ScriptUrl?pagename=$Group.$Title&query'
  3. Substitute the special values for $ScriptUrl, $Groupspaced, $Group,
     $Titlespace, $Title_, $Title, and $Tlink that depend on the pagename
     being passed as a parameter
  4. Substitute any remaining global variables in reverse alphabetic sequence
  
Thus, if $PageLogoFmt is defined as above, and the template contains

    <div id='wikilogo'>$PageLogoFmt</div>

then the resulting output will be exactly

    <div id='wikilogo'><a href='$ScriptUrl'><img src='$PageLogoUrl'
      border='0' alt='$WikiTitle' /></a></div>

where $ScriptUrl, $PageLogoUrl, etc. don't get replaced because such
replacements take place in step 3, whereas $PageLogoFmt didn't get
substituted until step 4.

The best solution I've come up with thus far to this problem is to add
a step 0 prior to all of the others that performs a substitution of
any variables ending in 'Fmt'.  But I'm concerned about unintended side
effects, as this function is literally at the core of so much of how
PmWiki operates.

So, I'm working on it.  :-)   Anyone see any problems with the step 0 I
propose?

Pm



More information about the pmwiki-users mailing list