[pmwiki-users] 2.2.0: add Site.SiteHeader and Site.SiteFooter

Patrick R. Michaud pmichaud at pobox.com
Thu Jun 21 01:16:05 CDT 2007


On Thu, Jun 21, 2007 at 01:03:46AM -0300, carlos.ab at gmail.com wrote:
> > Authors can't modify /pub/css/local.css, but they will be able to
> > modify a site header page if Proposal #2 takes effect.
> 
> But anywhere, users won't be able to re-define styles, as local.css 
> comes last when loaded by pmwiki, AFAIK.

Not exactly.  WikiStyles aren't the same thing as CSS stylesheet
classes, although they are indeed related, and undefined wikistyles
default to them.

Wikistyles typically place attributes into HTML tags.  For
example, a wikistyle of %color=blue% causes a "color: blue;"
style attribute to be added to a tag.  Thus markup of

    This is %color=blue% some example %% text.

produces

    <p>This is <span style='color:blue;'> some example </span> text.</p>

An author can use define= to create a wikistyle shortcut.
If an author writes

    %define=ocean color=blue%

    This is %ocean% some example %% text.

then they get the exact HTML output as above -- i.e.,

    <p>This is <span style='color:blue;'> some example </span> text.</p>

Note that using define= to create an %ocean% wikistyle does 
not result in a new ".ocean" CSS class, it simply acts as 
a shortcut for a set of attributes.

The relationship between wikistyles and CSS classes normally
comes about because PmWiki says that any *undefined* wikistyle 
shortcut automatically defaults to using a same-named CSS class.
In other words, if %xyz% isn't defined anywhere, then writing %xyz%
is basically the same as writing %class=xyz%.  So, markup of

    This is %xyz% some example %% text.

produces HTML that looks like

    <p>This is <span class='xyz'> some example </span> text.

This will of course use the .xyz class that may be defined in
any stylesheets, according to the standard CSS selection rules.

However, if the %xyz% wikistyle is defined, either earlier in the
page or in another page such as GroupHeader, then the wikistyle
will use that setting instead of the class= default.  Thus

    %define=xyz color=blue%

    This is %xyz% some example %% text.

produces

    <p>This is <span style='color:blue;'> some example </span> text.

Note that by redefining the %xyz% wikistyle in this way, the author
is no longer using any .xyz CSS class that may be coming from 
a stylesheet (like pub/css/local.css), but has instead explicitly
specified the properties to be used for the span of text.

This is an important point that is often missed:  Wikistyles are 
_not_ a way to create CSS stylesheets or CSS class definitions, 
they're simply a way for an author to say "apply these properties 
to this section of markup".  A wikistyle can use classes defined 
by a stylesheet (and many often default to doing so), but a
wikistyle can also choose to ignore the stylesheets and set its
own properties.

And thus authors _can_ locally declare wikistyles to use settings
other than those provided by a site's CSS stylesheets such as 
pub/css/local.css .  All that matters is that any wikistyle 
(re)definition appears before the wikistyle is used in the 
document.  Placing wikistyle definitions in a GroupHeader or
a sitewide page of some sort is a good way to get standard
wikistyles to apply across multiple pages.

I'm sure I've confused quite a few people with this description,
but hopefully I also clarified some things for others.  For now,
just go with whatever makes you most comfortable.  :-)

Pm



More information about the pmwiki-users mailing list