# Plugin Templatedateien einbinden

**URL:** <https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998>\
**Category:** Allgemein\
**Created:** [28. Mai 2017 um 07:15 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998 "2017-05-28T07:15:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [28. Mai 2017 um 07:15 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/1 "2017-05-28T07:15:26Z")

</div>

Liebes Forum 🙂 🙂

ich versuche gerade ein Plugin mit der neuen Pluginstruktur unter custom/plugin/ zu erstellen.

Und zwar ein ganz eifaches, das nur zwei Blöcke&nbsp;einer Templatedatei ersetzt. Ich habe sogar das shopware Buch, bekomme das aber einfach nicht hin.

Das Plugin heisst&nbsp;LoremQuestions

und besteht aus zwei Dateien:

…\custom\plugins\LoremQuestions\LoremQuestions.php

```
 'onPostDispatchFrontend'            
        ];
    }

    public function onPostDispatchFrontend()
    {
        $this->container->get('Template')->addTemplateDir(
            $this->getPath() . '/resources/Views/'
        );

    }
}

```

und&nbsp;…\custom\plugins\LoremQuestions\resources\Views\frontend\index\index.tpl

```
{extends file='parent:frontend/index/index.tpl'}
    {block name='frontend_index_after_body'}
        AAA
    {/block}

    {block name="frontend_index_page_wrap"}
        BBB
    {/block}

```

Habe wirklich schon viel probiert, aber die Blöcke werden einfach nicht überschrieben/angezeigt.

Wo könnte der Fehler liegen ?

Vielleicht könnte ja jamand ein Beispiel posten.

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [29. Mai 2017 um 09:58 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/2 "2017-05-29T09:58:43Z")

</div>

Ich möchte noch einmal an dieses Thema erinnern. Ich bekomme das einfach nicht hin&nbsp; ![Frown](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/569ff272a6dd35730487f053b5b3cd1f98b23eea.png "Frown")

---

<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. Mai 2017 um 10:44 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/3 "2017-05-29T10:44:30Z")

</div>

Überschreibst du das Standard Theme oder ein eigenes?

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [29. Mai 2017 um 11:01 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/4 "2017-05-29T11:01:02Z")

</div>

Ich überschreibe ein eigenes Theme. Sollte aber beides gehen.

---

<div class="post-metadata">

**Author:** ![NextMike](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@NextMike](https://forum.shopware.com/u/NextMike)\
**Post date:** [29. Mai 2017 um 11:13 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/5 "2017-05-29T11:13:07Z")

</div>

Recht beliebt ist ein Typo an dieser Stelle:

```
 $this->getPath() . '/resources/Views/'

```

Groß- und Kleinschreibung.&nbsp;

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [29. Mai 2017 um 11:33 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/6 "2017-05-29T11:33:27Z")

</div>

ja, … und dann ? 🙂

Hat bitte mal jemand ein simples Beispiel-Plugin ? Oder kann sagen, woran es liegt ?

Liebe Grüße

Kerstin 🙂

---

<div class="post-metadata">

**Author:** ![NextMike](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@NextMike](https://forum.shopware.com/u/NextMike)\
**Post date:** [29. Mai 2017 um 11:36 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/7 "2017-05-29T11:36:27Z")

</div>

> [@Kerstin83 schrieb:](https://forum.shopware.com/profile/10989/Kerstin83 "Kerstin83")
> 
> ja, … und dann ? ![:)](https://dub1.discourse-cdn.com/flex013/resources/emoji/smile.png ":)")
> 
> Hat bitte mal jemand ein simples Beispiel-Plugin ? Oder kann sagen, woran es liegt ?
> 
> Liebe Grüße
> 
> Kerstin ![:)](https://dub1.discourse-cdn.com/flex013/resources/emoji/smile.png ":)")

schau mal ob die Schreibung (Pfad) bei Dir passt&nbsp;

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [29. Mai 2017 um 11:51 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/8 "2017-05-29T11:51:49Z")

</div>

Eigentlich ja. Deswegen habe ich die Pfade mit angegeben, weil ich mir nicht ganz sicher bin. Könnt ihr mal bitte schauen?

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [29. Mai 2017 um 12:11 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/9 "2017-05-29T12:11:23Z")

</div>

Bitte, bitte postet doch mal ein kleines Beispiel. Mit Pfaden.

---

<div class="post-metadata">

**Author:** ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)\
**Post date:** [29. Mai 2017 um 12:29 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/10 "2017-05-29T12:29:42Z")

</div>

Hallo Kerstin,

habe das gerade mal gestestet.

Einmal unter /custom/plugins/Testplugin4 eine Datei „Testplugin4.php“ anlegen:

```
 'onFrontendPostDispatchBlog'
        ];
    }
    public function onFrontendPostDispatchBlog(\Enlight_Controller_ActionEventArgs $args)
    {
        $this->container->get('template')->addTemplateDir(
        $this->getPath() . '/Resources/views/'
        );
    }
}

```

Dann unter /custom/plugins/Testplugin4/Resources/views/frontend/blog/detail.tpl anlegen.

Bei mir sah die so aus:

```
{extends file='parent:frontend/blog/detail.tpl'}

{block name='frontend_index_content'}
    {$smarty.block.parent}
    Dies ist ein Test
{/block}

```

Dann hab ich im Frontend auch „Dies ist ein Test“ im Blog gesehen. Kannst du natürlich für jedes andere Template und Controller adaptieren.

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [29. Mai 2017 um 18:21 UTC](https://forum.shopware.com/t/plugin-templatedateien-einbinden/45998/11 "2017-05-29T18:21:16Z")

</div>

Vielen, vielen Dank, Moritz, das hat endlich geklappt 🙂 🙂 \*freu

Ich muss mal schauen, was an meinem Plugin eigentlich falsch ist.

Less einbinden habe ich jetzt auch geschafft.

Aber eine Frage noch, wie binde ich im neuen Plugin System Javascript ein ?

Liebe Grüße

Kerstin
