# Eigener Twig Modifier

**URL:** <https://forum.shopware.com/t/eigener-twig-modifier/62680>\
**Category:** Programmierung\
**Created:** [29. Oktober 2019 um 15:42 UTC](https://forum.shopware.com/t/eigener-twig-modifier/62680 "2019-10-29T15:42:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DenKon26](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@DenKon26](https://forum.shopware.com/u/DenKon26)\
**Post date:** [29. Oktober 2019 um 15:42 UTC](https://forum.shopware.com/t/eigener-twig-modifier/62680/1 "2019-10-29T15:42:17Z")

</div>

Hallo,

&nbsp;

In Smarty und mit SW5 hatte man die Möglichkeit eigene Smarty Modifier in sein Plugin zu integrieren, die man dann im Template verwenden konnte.

&nbsp;

Gibt es so eine Möglichkeit auch für SW6 und Twig oder aktuell noch nicht?

Falls ja gerne mit Code Beispiel oder Verweis auf die Doku 🙂

&nbsp;

Danke!

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [29. Oktober 2019 um 15:53 UTC](https://forum.shopware.com/t/eigener-twig-modifier/62680/2 "2019-10-29T15:53:15Z")

</div>

Twig filter, functions, extensions ?

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [30. Oktober 2019 um 09:34 UTC](https://forum.shopware.com/t/eigener-twig-modifier/62680/3 "2019-10-30T09:34:22Z")

</div>

Hallo,

da wir Twig im Standard verwenden, sollte diese Doku dir weiter helfen:&nbsp;[How to Write a custom Twig Extension (Symfony Docs)](https://symfony.com/doc/current/templating/twig_extension.html)  
Du kannst dich auch an die Shopware eigenen Extensions halten:&nbsp;[https://github.com/shopware/platform/tree/master/src/Core/Framework/Twig](https://github.com/shopware/platform/tree/master/src/Core/Framework/Twig)

Viele Grüße aus Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

**Author:** ![DenKon26](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@DenKon26](https://forum.shopware.com/u/DenKon26)\
**Post date:** [4. November 2019 um 11:00 UTC](https://forum.shopware.com/t/eigener-twig-modifier/62680/4 "2019-11-04T11:00:05Z")

</div>

> [@Michael Telgmann schrieb:](https://forum.shopware.com/profile/17553/Michael%20Telgmann "Michael%20Telgmann")
> 
> Hallo,
> 
> da wir Twig im Standard verwenden, sollte diese Doku dir weiter helfen:&nbsp;[https://symfony.com/doc/current/templating/twig\_extension.html](https://symfony.com/doc/current/templating/twig_extension.html)  
> Du kannst dich auch an die Shopware eigenen Extensions halten:&nbsp;[https://github.com/shopware/platform/tree/master/src/Core/Framework/Twig](https://github.com/shopware/platform/tree/master/src/Core/Framework/Twig)
> 
> Viele Grüße aus Schöppingen
> 
> ![cool](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "cool")&nbsp;Michael Telgmann

Hallo Michael,

Ok das ist schon mal ein erster Ansatz.

Wie genau ist die Konvention um einen eigenen Twig Modifier in ein Plugin zu integrieren?

Sehe ich das richtig, dass ich die entsprechende Extension Datei einfach anlege und Shopware diese selbst registriert? Oder wie genau muss ich diese bekannt machen, damit ich alles im Twig Template verwenden kann?

&nbsp;

VG  
Dennis

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [11. November 2019 um 09:28 UTC](https://forum.shopware.com/t/eigener-twig-modifier/62680/5 "2019-11-11T09:28:53Z")

</div>

Hallo Dennis,

Die Datei kannst du so erstmal in deinem Plugin anlegen wie du möchtest. Wichtig ist nur, dass du die Klasse entsprechend korrekt im Symfony DI Container registrierst. Siehe dazu im Core:&nbsp;[https://github.com/shopware/platform/blob/master/src/Core/Framework/DependencyInjection/services.xml#L226-L250](https://github.com/shopware/platform/blob/master/src/Core/Framework/DependencyInjection/services.xml#L226-L250)

Viele Grüße aus Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann
