Less Plugin - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13) +--- Thread: Less Plugin (/showthread.php?tid=6010) |
Less Plugin - mvlcek - 2014-03-26 Less plugin: This plugin helps you to use LESS to write your style sheets instead of CSS. (see http://leafo.net/lessphp/ for information on the syntax of LESS) The performance impact is minimal, as CSS files are generated when first needed and afterwards served directly to the site user. Just write a LESS file (e.g. here background.less with a variable color): Code: body { background-color: @color; } Then you can use this file within your template:
Code: <link rel="stylesheet" type="text/css" href="<?php get_less_css('background.less', array('color'=>'green')); ?>" />
Code: <link rel="stylesheet" type="text/css" href="<?php get_less_css('background.less', array('color'=>return_custom_field('color', 'white')), true); ?>" /> API: Code: function return_less_css($themeRelativeLessFile, $params=null, $multipleCSS=false) Compiles a LESS file to a parameter specific css file, if the less file is newer ($multipleCSS = true). The first parameter is the name of the LESS file, e.g. "default.less" (if it's directly in the theme directory) or "css/default.less". The second parameter is an associative array with the parameters for the LESS file and the last parameter must be true, if for each parameter set a new CSS file should be compiled and all these CSS files should be available at the same time. Returns the full URL of the generated CSS file. Code: function get_less_css($themeRelativeLessFile, $params=null, $multipleCSS=false) { For yet another CSS like syntax see the SCSS plugin. RE: Less Plugin - Oleg06 - 2014-03-26 why it works Code: return_custom_field('color', 'white') Code: return_special_field('color', 'white') (2014-03-26, 07:04:48)mvlcek Wrote: Less plugin: RE: Less Plugin - mvlcek - 2014-03-26 (2014-03-26, 17:42:03)Oleg06 Wrote: why it works I suppose you don't have a special view HTML/PHP code in your special page type definition. In this case the fields were not loaded and return_special_field didn't work. It's now fixed in version 1.2.2 of I18N Special Pages. RE: Less Plugin - Oleg06 - 2014-03-26 does not work. that is to use both plugins together not? Code: <link rel="stylesheet" type="text/css" href="<?php get_less_css('background.less', array( (2014-03-26, 18:51:42)mvlcek Wrote:(2014-03-26, 17:42:03)Oleg06 Wrote: why it works RE: Less Plugin - mvlcek - 2014-03-26 (2014-03-26, 20:28:15)Oleg06 Wrote: does not work. that is to use both plugins together not? You should check for errors by switching on debugging and checking the page source in the browser and the log file for errors. In above case there is a missing comma at the end of the third line. RE: Less Plugin - Oleg06 - 2014-03-26 Thanks, it works RE: Less Plugin - Oleg06 - 2014-03-26 I created a field of type image, and the code is generated Code: #tekstovyj-blok-39 { RE: Less Plugin - mvlcek - 2014-03-27 (2014-03-26, 23:54:11)Oleg06 Wrote: I created a field of type image, and the code is generated This seems to be a problem/feature of the lessPHP compiler and a ":" in the string. You can work around it by adding quotes around the string field, e.g. Code: get_less_css('background.less', array('image'=>'"'.return_custom_field('image', '').'"'), true); RE: Less Plugin - morvy - 2014-04-04 any possibility to extend this plugin with SCSS support ? RE: Less Plugin - mvlcek - 2014-04-05 (2014-04-04, 23:14:15)morvy Wrote: any possibility to extend this plugin with SCSS support ? See the SCSS plugin. RE: Less Plugin - mvlcek - 2014-07-12 Together with the Theme Settings plugin it is now easy to create configurable themes. RE: Less Plugin - cvrglj - 2015-07-10 Hi, if anybody interesting, I add in less.php in line 53 Code: $lessc->setFormatter("compressed"); and it output compressed css what is very nice! with regards, Darko from Slovenia RE: Less Plugin 2022 PHP8.1 - jofer - 2022-12-19 Martins Less Plugin is still working w/ PHP8.1. Replace lessc.inc.php in plugins/less by wikimedias lessc.inc.php. >* (patched by mvlcek to avoid exceptions with certain string variables) At this moment, I have no idea about Martins patches. Maybe later. Sources: leafo/lessphp (old one) wikimedia/less.php (actual) Quote:Transitioning from Leafo/lessphp ... and add Subdir lib into plugins/less. Works fine for me. :-) Jo |