Jump to content


Photo
PageLess

Doesn't work with LESS Variables?



Best Answer Evan Mattson , 29 March 2013 - 07:28 PM

This topic was tagged with PageLESS but there are screenshots of PageLESS and LESS Developer so I'm not exactly sure what product this topic is indended for.

 

First of all I want to say that both PageLESS and LESS Developer support LESS variables 100%.

 

From your screenshots, it looks like you're trying to define LESS variables in a .less file with LESS Developer and then call those up in PageLESS.  That's not going to work.  This is not a shortcoming of the product, but just how the LESS compiler works.

 

In order for new LESS variables to be available in PageLESS, they need to be properly added using the 'pless_vars' filter OR present in your theme's colors.less or variables.less override files if you're using them - otherwise the core frameworks files by the same name will be loaded.  I recommend just using the filter, it's very easy and doesn't require overriding any files.

 

Use this code in your functions.php to add LESS variables:

 
<?php

add_filter('pless_vars', 'my_custom_vars);

function my_custom_vars( $vars ) {

$vars['tkcolor1'] = '#000000';
$vars['tkcolor2'] = '#ffffff';

return $vars;
}

Hope that helps!

Go to the full post


This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1 CliffordP†

CliffordP

    Advocate

  • DMS Subscriber†

  • 512 posts

Posted 22 March 2013 - 02:30 PM

http://cl.ly/image/0N3U4428363v

woops, meant this: http://cl.ly/image/0I1p1h0N2c2w



#2 Jenny†

Jenny

    Advocate

  • DMS Subscriber†
  • 2924 posts

Posted 28 March 2013 - 08:22 PM

I have alerted the developer of this topic.



#3 Evan Mattson

Evan Mattson

    Super Member

  • Members

  • 243 posts

Posted 29 March 2013 - 07:28 PM   Best Answer

This topic was tagged with PageLESS but there are screenshots of PageLESS and LESS Developer so I'm not exactly sure what product this topic is indended for.

 

First of all I want to say that both PageLESS and LESS Developer support LESS variables 100%.

 

From your screenshots, it looks like you're trying to define LESS variables in a .less file with LESS Developer and then call those up in PageLESS.  That's not going to work.  This is not a shortcoming of the product, but just how the LESS compiler works.

 

In order for new LESS variables to be available in PageLESS, they need to be properly added using the 'pless_vars' filter OR present in your theme's colors.less or variables.less override files if you're using them - otherwise the core frameworks files by the same name will be loaded.  I recommend just using the filter, it's very easy and doesn't require overriding any files.

 

Use this code in your functions.php to add LESS variables:

 
<?php

add_filter('pless_vars', 'my_custom_vars);

function my_custom_vars( $vars ) {

$vars['tkcolor1'] = '#000000';
$vars['tkcolor2'] = '#ffffff';

return $vars;
}

Hope that helps!



#4 CliffordP†

CliffordP

    Advocate

  • DMS Subscriber†

  • 512 posts

Posted 30 March 2013 - 01:42 AM

Evan, yes, you understood my question completely (and put into words what I wasn't sure how to say).

 

Thanks for the code snippet.

 

I tested and when I put those LESS variables in my child theme's style.less instead of directly into the LESS compiler, the LESS Developer plugin did "work" correctly with them.

 

Thanks.