chtiland
Hello,
Is there a way to use variables in a plugin's CSS file ?
Variables are set on plugin's configuration through admin interface.
Thanks :)
torpedo
Hi,
I think the main problem is the browser compatibility.
See here at the bottom of the page
https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables
chtiland
Hi,
Thanks for your answer, but I want to be able to use varaibles in plugin as those defined in style.ini.
Example : In Dokiwiki's settings -> plugin's section (eg. : MyPlugin), choosing icon size (16 / 24 / 32 or 64).
In plugin's style.css using __MyPluginIconSize__.
The only one way I found is to define one style per icon in CSS and use variable do define style in my php file (e.g. syntax.php)
torpedo
One idea could be to parse your css file before it gets sent to the server and replace the value(s) that you want to change.
It's not very difficult to implement.
In your action.php create a specific function which reads the variable $this->getConf('my_var');
compares it with its current value and then, with preg_metch, rewrites your style.css.
chtiland
Thanks Torpedo, finally I create several CSS class (e.g. icon16px, icon24px ...) and use variable in my php script to change class.
I though there were a easiest way to use var in plugin's CSS as in DW with style.ini
Thanks for helping, have a nice day ;)
torpedo
If I'm not mistaken, the plugin styling works in much the same way I described, that is it replaces the values in your style.ini.
Have a look at lib/plugins/styling/admin.php