Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
Can a template handle the event 'CSS_STYLES_INCLUDED'?
Avatar
LarsDW223 #1
Member since Sep 2014 · 384 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Subject: Can a template handle the event 'CSS_STYLES_INCLUDED'?
Hello All,

I got a question regarding the event CSS_STYLES_INCLUDED. Is it possible that a template handles this event?

I saw that templates e.g. can handle the event TPL_METAHEADER_OUTPUT by inserting code like this in the template's code:

$EVENT_HANDLER->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', null, 'callback_function_name');

But as far as I understood this will not work for the event CSS_STYLES_INCLUDED. The reason - from my understanding - is, that the CSS code generated and delivered by DokuWiki is generated in css.php which is referenced by templates through a link. That way, css.php is run as it's own process/request. And, on handling of a request by css.php no template code seems to be included/executed. So my impression is that actually only plugins can use the event CSS_STYLES_INCLUDED.

So, is my understanding correct? Or is there an existing way how a template can handle the event which I did not see? Any feedback is appreciated.

Thanks and greetings,
Lars
Avatar
Michaelsy #2
Member since Jun 2015 · 745 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
I'm not sure to understand your final purpose. But maybe the following will do what you want:

You can involve your own CSS-files via style.ini and in this way they become a part of the output of css.php
Take a look at lib/tpl/dokuwiki/style.ini

Another idea:
Call your own css.php (e. g. css_larsdw223.php) and include the ordinary css.php

HTH - Michael Sy.
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
Avatar
LarsDW223 #3
Member since Sep 2014 · 384 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Thanks Michael, but I think that's not exactly what I want.

This is why I came up with that question:

I played around with creating my own template and wanted to make it adjustable. IMHO the actual options for making templates customizable are not bad but have some limitations:

- css or less files listed in the template's style.ini are always included/sent to the client even if e.g. some might not be of use because of the actual template configuration (e.g. some kind of color or layout theme).

- the "Template Style Settings" are also easy to use but only work in a static way

If a template for example generates a HTML page with a "dynamic" structure depending on the configuration and other parameters (e.g. current page, logged in user...) then there is no way to only use the css or less files which are actually required for the actual context/situation (as far as I know).

I have the impression that the actual way in which most templates solve this is to have all their CSS code included and then assign the classes which is really needed to the HTML elements. Of course this usually is fine but I thought if a template has css or less files which mutually exclude each other then it would be nice to only sent the files which are required.
Avatar
LarsDW223 #4
Member since Sep 2014 · 384 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Another remark:

I know a template can add own files using the event TPL_METAHEADER_OUTPUT but then I guess it has to handle things like caching and calling the less compiler for less files itself.

Using the event CSS_STYLES_INCLUDED would be much more comfortable because the template could add some files and the core (css.php) would handle all the loading, less-compiling and caching stuff.
Avatar
LarsDW223 #5
Member since Sep 2014 · 384 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Another idea:
Call your own css.php (e. g. css_larsdw223.php) and include the ordinary css.php

Although that would be a feasible solution I dislike it because it would be a quite big code duplication and might not be future proof.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-03-21, 23:17:49 (UTC +01:00)