Attached patch allows you to define your variables inside my_theme.info and alters the theme settings to end-users can override those settings without the need to alter the theme. If jquery_colorpicker is installed and active, they see a colorpicker. This only works if you don't declare the same variable inside your my_theme.css.less.

This patch also adds a new hook so developers can define custom php functions to be used inside less (http://leafo.net/lessphp/docs/index.html#custom_functions, added in version 0.3.1)

Example
my_theme.info

less_use_default = TRUE
less[@bckcolor] = #222266
less[@pagecolor] = darken(@bckcolor, 5%)
less[@textcolor] = #ffffff
less[@linkcolor] = @textcolor
less[@linkactive] = rgb(0, 88, 107)
less[@buttontext] = rgb(0, 88, 107)

Theme settings
less_support_theme_settings.png

Comments

attiks’s picture

StatusFileSize
new4.58 KB

Small fix, new patch attached

stovak’s picture

Ah. Mah. Zing. This is an awsome contrib. It should be adopted immediately.

rbayliss’s picture

These are two awesome ideas, but IMO, the theme settings should be added via an alter hook. I also don't think the LESS module should provide any kind of UI for setting these variables - let the theme do it and let the theme implement an alter hook to push those variables into the array. Otherwise, two thumbs up.

jay.dansand’s picture

I may have accidentally almost-duped this issue/solved it a little differently (my solution passes functions and variables via code to drupal_add_css()) in #1543276: Support passing/defining LESS variables/functions via drupal_add_css() and theme.info

The solutions are a little different since one is code-driven and the other uses .info settings, so perhaps we can merge them and keep both.

attiks’s picture

I'm all in favor of merging, but i think our goals are different:
Mine was to allow an end user to change some variables using the appearance page and for all pages on the site.
Yours look like you want to be able to alter each css before it's gets added depending on some condition (like path, content type, ...)

Or did I miss something?

corey.aufang’s picture

Does this patch allow you to use functions registered with ->registerFunction() in the default or user entered values?

attiks’s picture

You can use the function inside any less file, with or without entered values

jay.dansand’s picture

My goal is two-fold:
1: (original goal) To let site developers change variables and functions passed to LESS files, regardless of why/when (could be across the whole site, for example).
2: I discovered that #1 doesn't work unless you find some way to invalidate the LESS file (AND the aggregated CSS if you have Performance/Aggregate CSS turned on in your site) - that's why I added the cache management/$tag/$expire=TRUE stuff to my code. #1 doesn't work without it, because if you change the variables passed to LESS, it won't recompile the destination file and your new settings will not take effect.

So, I think #1543276: Support passing/defining LESS variables/functions via drupal_add_css() and theme.info is the closest thing to a solution. I've wrapped up the functionality in this issue into the latest patch as well, so everything should be covered from both of these issue tickets. Could you test the patch and make sure it does what your patch in this issue did?

jelle_s’s picture

StatusFileSize
new4.49 KB

re-rolled patch

jay.dansand’s picture

I think #1543276: Support passing/defining LESS variables/functions via drupal_add_css() and theme.info is the latest version of this issue, and includes both this functionality and some related capabilities.

corey.aufang’s picture

Take a look at the latest dev.

Settings can be adjusted from the specific theme's configuration page.

corey.aufang’s picture

Status: Needs review » Closed (duplicate)

  • Commit e3475af on 7.x-2.x, 7.x-3.x, 7.x-4.x by corey.aufang:
    First commit of functionality related to [#1543276] and [#1433948].