I have several variables (hex colors) defined in a database. I need to pass these variables from MySQL to a LESS.js stylesheet via PHP. Possible?
If not, any advice on a way to do something similar? The lighten and darken variables are key.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best approach that come in my mind is to dynamic generate a LESS file using PHP (including your vars).
1\ You will need to include a new style sheet in your HTML pages.
2\ In your
style.phpinclude your PHP vars as follows:3\ Then at the bottom (or after you LESS var declaration) of this
style.phpadd all your needed imports as follows:This will works like a clock.
There is an article you can read about CSS Variables with PHP written by Chris Coyier.
Another not recommended alternative is compiling you LESS files in client-side, you could manually compile them and pass PHP vars doing the following: