{"id":43905,"date":"2016-03-23T10:41:02","date_gmt":"2016-03-23T10:41:02","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=43905"},"modified":"2016-03-23T10:42:59","modified_gmt":"2016-03-23T10:42:59","slug":"use-less-opencart","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/use-less-opencart\/","title":{"rendered":"Use LESS in Opencart"},"content":{"rendered":"<p>Here, we will learn how to integrate LESS styling with the Opencart. First of all, we have to download the composer installer in the root of our Opencart using the command:<\/p>\n<pre class=\"brush:powershell\">curl -s http:\/\/getcomposer.org\/installer | php<\/pre>\n<p>Then, we have to create a composer.json file in the root and put the following lines into it:<\/p>\n<pre class=\"brush:js\">{\r\n    \"require\": {\r\n        \"leafo\/lessphp\": \"0.4.0\"\r\n    }\r\n}<\/pre>\n<p>After pasting the above lines, we have to install the dependencies using the command:<\/p>\n<pre class=\"brush:shell\">php composer.phar install<\/pre>\n<p>It will create a vendor folder by default in which the LESS packages will be stored. To make an access to these files, I have included the package in the controller &#8216;module\/less.php&#8217;. So, here&#8217;s the code of controller in which I have written the LESS hard-coded.<\/p>\n<pre class=\"brush:php\">&lt;?php\r\nclass ControllerModuleLess extends Controller {\r\n public function index() {\r\n $this-&gt;load-&gt;language('module\/less');\r\n\r\n $data['heading_title'] = $this-&gt;language-&gt;get('heading_title');\r\n\r\n require_once('vendor\/leafo\/lessphp\/lessc.inc.php');\r\n $less = new lessc;\r\n\r\n $css = \"@base: 24px;\r\n @border-color: #B2B;\r\n\r\n .underline { border-bottom: 1px solid green }\r\n\r\n #header {\r\n color: black;\r\n border: 1px solid @border-color + #222222;\r\n\r\n .navigation {\r\n font-size: @base \/ 2;\r\n a {\r\n .underline;\r\n }\r\n }\r\n .logo {\r\n width: 300px;\r\n :hover { text-decoration: none }\r\n }\r\n }\";\r\n\r\n $data['css'] = $less-&gt;compile($css);\r\n\r\n if (file_exists(DIR_TEMPLATE . $this-&gt;config-&gt;get('config_template') . '\/template\/module\/less.tpl')) {\r\n $this-&gt;response-&gt;setOutput($this-&gt;load-&gt;view($this-&gt;config-&gt;get('config_template') . '\/template\/module\/less.tpl', $data));\r\n } else {\r\n $this-&gt;response-&gt;setOutput($this-&gt;load-&gt;view('default\/template\/module\/less.tpl', $data));\r\n }\r\n \r\n }\r\n}<\/pre>\n<p>The LESS must be written in the separate file.<\/p>\n<p>The LESS can also be\u00a0read directly from a file and compiled as $less-&gt;compile(&#8216;file_path&#8217;);<\/p>\n<p>Here, is the simple code of the view file of less just showing the CSS:<\/p>\n<pre class=\"brush:xml\">&lt;h3&gt;&lt;?php echo $heading_title; ?&gt;&lt;\/h3&gt;\r\n&lt;style&gt;\r\n&lt;?php echo $css; ?&gt;\r\n&lt;\/style&gt; \r\n<\/pre>\n<p>The output in the front end can be seen by inspecting in\u00a0HTML and it is as shown:<\/p>\n<div id=\"attachment_43907\" style=\"width: 500px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-43907\" class=\"size-full wp-image-43907\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/03\/less_output.png\" alt=\"LESS INTO CSS\" width=\"490\" height=\"293\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/03\/less_output.png 490w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/03\/less_output-250x149.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/03\/less_output-300x179.png 300w\" sizes=\"(max-width: 490px) 100vw, 490px\" loading=\"lazy\" \/><p id=\"caption-attachment-43907\" class=\"wp-caption-text\">LESS INTO CSS<\/p><\/div>\n<p>For a thorough knowledge of the LESS, please do visit\u00a0LESS<a href=\"http:\/\/lesscss.org\/\">\u00a0Documentation<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here, we will learn how to integrate LESS styling with the Opencart. First of all, we have to download the composer installer in the root of our Opencart using the command: curl -s http:\/\/getcomposer.org\/installer | php Then, we have to create a composer.json file in the root and put the following lines into it: { <a href=\"https:\/\/webkul.com\/blog\/use-less-opencart\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":70,"featured_media":41008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78,1895,305,13],"tags":[217,1896,2071,2057],"class_list":["post-43905","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css3","category-less","category-opencart","category-php","tag-css","tag-less","tag-opencart","tag-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use LESS in Opencart - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/use-less-opencart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use LESS in Opencart - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Here, we will learn how to integrate LESS styling with the Opencart. First of all, we have to download the composer installer in the root of our Opencart using the command: curl -s http:\/\/getcomposer.org\/installer | php Then, we have to create a composer.json file in the root and put the following lines into it: { [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/use-less-opencart\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-23T10:41:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-23T10:42:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vikhyat Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vikhyat Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/\"},\"author\":{\"name\":\"Vikhyat Sharma\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/af7160d2546c64a1856ab1b5ce77d9b0\"},\"headline\":\"Use LESS in Opencart\",\"datePublished\":\"2016-03-23T10:41:02+00:00\",\"dateModified\":\"2016-03-23T10:42:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/\"},\"wordCount\":198,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"keywords\":[\"css\",\"less\",\"opencart\",\"PHP\"],\"articleSection\":[\"CSS3\",\"LESS\",\"opencart\",\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/use-less-opencart\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/\",\"url\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/\",\"name\":\"Use LESS in Opencart - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"datePublished\":\"2016-03-23T10:41:02+00:00\",\"dateModified\":\"2016-03-23T10:42:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/use-less-opencart\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/use-less-opencart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use LESS in Opencart\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/af7160d2546c64a1856ab1b5ce77d9b0\",\"name\":\"Vikhyat Sharma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7c9c700cc2d7120c9faf1ab3392b4e533808ba197f58c0441d6caecc68179e12?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7c9c700cc2d7120c9faf1ab3392b4e533808ba197f58c0441d6caecc68179e12?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Vikhyat Sharma\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/vikhyat-sharma83\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Use LESS in Opencart - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/use-less-opencart\/","og_locale":"en_US","og_type":"article","og_title":"Use LESS in Opencart - Webkul Blog","og_description":"Here, we will learn how to integrate LESS styling with the Opencart. First of all, we have to download the composer installer in the root of our Opencart using the command: curl -s http:\/\/getcomposer.org\/installer | php Then, we have to create a composer.json file in the root and put the following lines into it: { [...]","og_url":"https:\/\/webkul.com\/blog\/use-less-opencart\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-03-23T10:41:02+00:00","article_modified_time":"2016-03-23T10:42:59+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","type":"image\/png"}],"author":"Vikhyat Sharma","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Vikhyat Sharma","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/"},"author":{"name":"Vikhyat Sharma","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/af7160d2546c64a1856ab1b5ce77d9b0"},"headline":"Use LESS in Opencart","datePublished":"2016-03-23T10:41:02+00:00","dateModified":"2016-03-23T10:42:59+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/"},"wordCount":198,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","keywords":["css","less","opencart","PHP"],"articleSection":["CSS3","LESS","opencart","php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/use-less-opencart\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/","url":"https:\/\/webkul.com\/blog\/use-less-opencart\/","name":"Use LESS in Opencart - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","datePublished":"2016-03-23T10:41:02+00:00","dateModified":"2016-03-23T10:42:59+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/use-less-opencart\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/use-less-opencart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Use LESS in Opencart"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/af7160d2546c64a1856ab1b5ce77d9b0","name":"Vikhyat Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7c9c700cc2d7120c9faf1ab3392b4e533808ba197f58c0441d6caecc68179e12?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7c9c700cc2d7120c9faf1ab3392b4e533808ba197f58c0441d6caecc68179e12?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Vikhyat Sharma"},"url":"https:\/\/webkul.com\/blog\/author\/vikhyat-sharma83\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/43905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/70"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=43905"}],"version-history":[{"count":2,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/43905\/revisions"}],"predecessor-version":[{"id":43909,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/43905\/revisions\/43909"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/41008"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=43905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=43905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=43905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}