[pmwiki-users] style sheets order from a directive function
Petko Yotov
5ko at 5ko.fr
Sat Jan 16 12:40:23 CST 2010
On Saturday 16 January 2010 17:50:58, V.Krishn wrote :
> Here I would like to load
>
> <!--infoboxLibFmt-->
> <link rel='stylesheet' type='text/css'
> href='/pub/apps/pmwiki/cookbook/infobox/infobox.css' />
> .....
> Before the line
> <link rel='stylesheet' type='text/css'
> href='http://insteps.net/pr/a/pmwiki/pub/css/local.css' />
Right, a custom header $HTMLHeaderFmt['recipe'] appears in some cases before,
in some cases after local.css. I am not sure why.
There are two workarounds. First is to @import the external stylesheet from
the inline css, like this [1] :
SDVA($HTMLStylesFmt, array('myrecipe'=>'@import "/path/to/style.css";'));
Second workaround is to force your HTML header at the beginning of the array,
before all other entries :
array_unshift($HTMLHeaderFmt, array('myrecipe' => "<link rel=.../>"));
This will appear after [2] the skin css file, but before the internal PmWiki
styles .indent, .outdent, .vspace etc. and before any local css files.
Petko
[1] Reference : http://www.w3.org/TR/CSS2/cascade.html#at-import
[2] Individual skins may have different settings, and $HTMLHeaderFmt may
appear before the skin.css file, but in the default configuration/skin it is
after.
> > On Friday 15 January 2010 23:48:13, V.Krishn wrote :
> > > Setting $HTMLHeaderFmt['myrecipe'] = 'value'
> > > from within directive function results in being set after user defined
> > > css like local.css..etc.
> > >
> > > I am thinking of using
> > > $array2['styles'] = $HTMLHeaderFmt['styles'];
> > > $array2['infobox'] = "link to css";
> > > $HTMLHeaderFmt = array_merge($array2, $HTMLHeaderFmt);
> > >
> > > I hope this would be ok?
> > > I would suggest if pmwiki calls the user defined styles to be loaded at
> > > the end of execution or can this presently be done by changing some
> > > variable?
> >
> > Normally, a recipe would place directly the CSS in a variable like this:
> > $HTMLStylesFmt['myrecipe'] = 'a.ext {color:green;}'; # [1]
> >
> > And not in $HTMLHeaderFmt.
> >
> > This should place the new CSS before local CSS files loaded from pub/css,
> > and a wiki could override these locally.
> >
> > Even better, your recipe could define your styles with SDVA() :
> > SDVA($HTMLStylesFmt, array('myrecipe'=>'a.ext {color:green;}'));
> >
> > (SDVA = Set Default value in array, unless the value is defined.)
> >
> > This way, an admin could replace the recipe's CSS via a line like [1]
> > above in config.php.
> >
> > Petko
>
More information about the pmwiki-users
mailing list