# Plugins, Frage zu CSS und LESS

**URL:** <https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531>\
**Category:** Programmierung\
**Created:** [22. Mai 2015 um 17:36 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531 "2015-05-22T17:36:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![benblub](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@benblub](https://forum.shopware.com/u/benblub)\
**Post date:** [22. Mai 2015 um 17:36 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/1 "2015-05-22T17:36:11Z")

</div>

Ich wollte mal fragen wir ihr das am besten macht. Ohne Einstellungsmöglichkeiten werden bei den Plugins CSS und LESS in separaten Dateien ausgelagert und eingebunden. Wenn ich dem User Einstellungsmöglichkeiten von den Styles gebe müssen ja Smarty Variablen genommen werden, welches ich bisher über in den \*.tpl Dateien gelöst habe. Gibt es da eine elegantere Möglichkeit die Vars an \*.css oder less weiter zu reichen? je nach var in der tpl ein anderes File zu laden wäre ein Weg, in meinen Augen aber nicht wirklich optimal…

---

<div class="post-metadata">

**Author:** ![Creatixx](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@Creatixx](https://forum.shopware.com/u/Creatixx)\
**Post date:** [23. Mai 2015 um 10:54 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/2 "2015-05-23T10:54:50Z")

</div>

Hi du kannst doch deine Konfiguration aus Bootstrap heraus direkt an deine .less Files übergeben! Schau dazu mal in die [DevDocs](https://devdocs.shopware.com/developers-guide/shopware-5-plugin-update-guide/).

---

<div class="post-metadata">

**Author:** ![benblub](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@benblub](https://forum.shopware.com/u/benblub)\
**Post date:** [23. Mai 2015 um 12:47 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/3 "2015-05-23T12:47:40Z")

</div>

ahh danke, ja lesen kann von Vorteil sein^^

---

<div class="post-metadata">

**Author:** ![benblub](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@benblub](https://forum.shopware.com/u/benblub)\
**Post date:** [28. Mai 2015 um 13:46 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/4 "2015-05-28T13:46:13Z")

</div>

Ich habe mir ganze nun angeschaut und auf den Git Labs und anderen Plugins mal nachgeschaut. So ganz ist mir das aber noch nicht klar geworden. Bevor ich jetzt ewig am rumprobieren bin, dachte ich mir ich frage hier einfach nochmal nach. Über ein kleines Code Beispiel würde ich mich sehr freuen. Ich möchte verschiedene Vars an Less übergeben welche dann die default Werte im LESS File ersetzen. `public function addLessFiles(Enlight\_Event\_EventArgs $args) { $less = new \Shopware\Components\Theme\LessDefinition( //configuration array( ".devpro\_xy\_container" =\> array( "height:" =\> $this-\>Config()-\>devpro\_xy\_container\_height ) ),` LESS File [code] @media screen and(min-width: @tabletViewportWidth) { .devpro\_xy\_container { height: 3rem; //

---

<div class="post-metadata">

**Author:** ![benblub](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@benblub](https://forum.shopware.com/u/benblub)\
**Post date:** [28. Mai 2015 um 15:23 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/5 "2015-05-28T15:23:04Z")

</div>

Das wäre mein 2. Ansatz bisher auch ungetestet. Wie schon zuvor erwähnt würde ich mich über nen kleines Codebeispiels freuen bevor ich nun alles durchtesten muss. ` //import directory $this-\>Path() . '/Views/frontend/\_public/src/less/all.less' ); $less-\>setVariables(array( "height" =\> $this-\>Config()-\>devpro\_xy\_container\_height )); $less-\>compile(".devpro\_xy\_container { height: @height; }", $this-\>Path() . '/Views/frontend/\_public/src/less/all.less'); return new Doctrine\Common\Collections\ArrayCollection(array($less)); `

---

<div class="post-metadata">

**Author:** ![Creatixx](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@Creatixx](https://forum.shopware.com/u/Creatixx)\
**Post date:** [28. Mai 2015 um 17:50 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/6 "2015-05-28T17:50:52Z")

</div>

Nur mal grob und ohne Defaultwerte: `public function addLessFiles(Enlight\_Event\_EventArgs $args) { $less = new \Shopware\Components\Theme\LessDefinition( //configuration array( 'varfürless' =\> $this-\>Config()-\>get('varausconfig') ), //less files to compile array( \_\_DIR\_\_ . '/Views/frontend/\_public/src/less/all.less' ), //import directory \_\_DIR\_\_ ); return new Doctrine\Common\Collections\ArrayCollection(array($less)); }` less: ` .blablub { height: @varfürless; } `

---

<div class="post-metadata">

**Author:** ![benblub](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@benblub](https://forum.shopware.com/u/benblub)\
**Post date:** [28. Mai 2015 um 17:57 UTC](https://forum.shopware.com/t/plugins-frage-zu-css-und-less/27531/7 "2015-05-28T17:57:35Z")

</div>

Besten Dank :thumbup:
