[pmwiki-users] style sheets order from a directive function

V.Krishn vkrishn at insteps.net
Sat Jan 16 13:46:47 CST 2010


On Sunday 17 Jan 2010 12:10:23 am you wrote:
> 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";'));

I would not go for this method for various implementation reasons...

>
> 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=.../>"));

Thanks, I thought of this and would be my second choice, because the array 
created from this would not create $HTMLHeaderFmt['myrecipe'] (associative) 
but $HTMLHeaderFmt[<num>] (normal array).

[3]
I am thinking of using this:
$temp['styles'] = $HTMLHeaderFmt['styles'];
$temp['infobox'] = "<link rel=.../>";
$HTMLHeaderFmt = array_merge($temp, $HTMLHeaderFmt);
This seems to work.
I hoped if pmwiki calls the user defined styles to be loaded at the 
end of execution? The idea of having local.css is for overriding syles called 
before.

I am only concerned that this does not cause any issues with multiple recipes 
setting their entries in $HTMLHeaderFmt.

>
> 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



-- 
Regards,
V.Krishn



More information about the pmwiki-users mailing list