[pmwiki-users] Problems with the embedded CSS in pmwiki.php

Patrick R. Michaud pmichaud at pobox.com
Fri Oct 27 12:27:08 CDT 2006

On Fri, Oct 27, 2006 at 04:17:49PM +0100, marc wrote:
> Something that's been bothering me for a while, but might be the result
> of misunderstanding something is the CSS and style ordering.
> Currently, in a skin template,
>   <!--HTMLHeader-->
> must come after the skin's
>   <link rel='stylesheet' ... skin.css
> because HTMLHeader adds local.css - and other CSSs that might be listed
> in $PageCSSListFmt.

Yes, this is the preferred mechanism.

> The problem with this order is that the pmwiki.php embedded
>   $HTMLStylesFmt['pmwiki'] = "
> then overrides some elements in the skin template. The problems this
> introduces then have to be fixed in pub/local.css

As one might expect with PmWiki, there are other options... :-)

Short answer:  The short answer is that a skin that wants to 
override the pmwiki.php embedded styles can do the following 
in skin.php:

    global $HTMLStylesFmt;
    $HTMLStylesFmt['skin'] = "...css overrides here...";

These definitions will come after the pmwiki defaults, but before
pub/css/local.css and other administrator-defined styles.

A skin that wants to completely replace the pmwiki.php defaults
with its own can do the following in skin.php:

    global $HTMLStylesFmt;
    $HTMLStylesFmt['pmwiki'] = '';

A skin can also insert its definitions between the default
styles and administrator styles by using:

    global $HTMLHeaderFmt;
    $HTMLHeaderFmt['skin'] = 
      "<link rel='stylesheet' href='\$SkinDirUrl/skin.css' type='text/css' />";

> Nevertheless, what I'd like to see is the removal of the embedded CSS in
> pmwiki.php. Knowing Patrick, I'm sure it's there for a reason, but it
> sure don't seem purty.

Long answer:  The reason why pmwiki.php embeds the CSS is to
reduce the overhead on skin authors and to preserve an upgrade path.

The styles defined by $HTMLStylesFmt['pmwiki'] are really the
essential ones that are needed for several of PmWiki's core
markups.  Without these in place, a number of PmWiki's built-in
features simply won't work.

In the past many have indicated that we should "dis-embed" the CSS
from pmwiki.php, and require every skin author to include these
minimal definitions (possibly modified) in the skin's .css file.
This slightly increases the work required to develop a skin,
because the skin author has to copy the definitions somewhere.
But more importantly, moving all of PmWiki's CSS properties into 
the skins can make future PmWiki upgrades a bit of a pain, because 
when a style definition is added or changed in the core, every
existing skin would then need to be modified to incorporate the 
new minimal specification.  I prefer to avoid that level of
coupling between core and skins.

The current approach allows skin CSS properties to be completely
decoupled from CSS properties needed for core and recipe markups.  
In fact, in this sense pmwiki.php uses $HTMLStylesFmt[] in exactly 
the same way that recipes do.  $HTMLStylesFmt[] allows 
module-specific CSS properties to be injected into the output 
without the skin ever having to be aware of them, while preserving 
the capability for skins and/or administrators to override the 
module-specific properties if they wish to do so.

(Note:  the above information probably belongs in a PmWiki.Design
page or in Cookbook.SkinGuidelines or something like that.  I'll
see about adding it in the near future.)



More information about the pmwiki-users mailing list