# Plugin: Uncaught SmartyException: directory not allowed by security setting

**URL:** <https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703>\
**Category:** Programmierung\
**Created:** [9. Oktober 2017 um 09:34 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703 "2017-10-09T09:34:05Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![puhas](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@puhas](https://forum.shopware.com/u/puhas)\
**Post date:** [4. Dezember 2017 um 16:33 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/21 "2017-12-04T16:33:00Z")

</div>

Hallo [@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl „Patrick Stahl“)‍

könntest du bitte noch was zu meiner Frage obendrüber sagen? Kann man im Event **Theme\_Inheritance\_Template\_Directories\_Collected** auch schon ein **Smarty Plugin** laden? Wenn ja, wie?

Dankeschön

&nbsp;

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [5. Dezember 2017 um 07:08 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/22 "2017-12-05T07:08:14Z")

</div>

Moin @puhas‍,

das kann ich dir gerade nicht ganz genau sagen, müsstest du einfach mal ausprobieren.  
Das kannst du ja erstmal Quick & Dirty direkt in _engine/Shopware/Components/Theme/Inheritance.php#193_ hiermit versuchen:

```
Shopware()->Template()->registerPlugin(...);

```

Sollte das funktionieren, kannst du ja den sauberen Weg über einen Subscriber und den DI-Container wählen.

Gruß,  
Patrick&nbsp; ![Shopware](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "Shopware")

---

<div class="post-metadata">

**Author:** ![ottscho](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@ottscho](https://forum.shopware.com/u/ottscho)\
**Post date:** [5. Dezember 2017 um 07:29 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/23 "2017-12-05T07:29:54Z")

</div>

Guten Morgen [@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl „Patrick Stahl“)‍,

kommst du evtl. diese Woche zum Problem von&nbsp;@mowlwurf‍?  
Wäre super.

Grüße  
Ottscho

---

<div class="post-metadata">

**Author:** ![puhas](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@puhas](https://forum.shopware.com/u/puhas)\
**Post date:** [5. Dezember 2017 um 12:30 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/24 "2017-12-05T12:30:38Z")

</div>

> Das kannst du ja erstmal Quick & Dirty direkt in _engine/Shopware/Components/Theme/Inheritance.php#193_ hiermit versuchen:
> 
> Shopware()-\>Template()-\>registerPlugin(…);
> 
> &nbsp;

Danke Patrick, mit

`Shopware()->Template()->addPluginsDir( __DIR__. '/SmartyPlugins/');`

funktioniert es schon mal.

Habe zu kompliziert gedacht ![Gasp](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/11de454286d9e6eb62eece226c8fe8ae7ec6b1be.png "Gasp")

---

<div class="post-metadata">

**Author:** ![mowlwurf](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mowlwurf](https://forum.shopware.com/u/mowlwurf)\
**Post date:** [6. Dezember 2017 um 11:12 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/25 "2017-12-06T11:12:14Z")

</div>

So, dank [@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl “Patrick Stahl”)‍ ist mein Problem nun auch geklärt,

hatte mit einer alten Plugin Template Struktur und der folgenden Funktion zu tun.

```
$view->extendsTemplate('frontend/plugins/mein_plugin/listing.tpl');

```

Diese ist deprecated und hat im Listing in Verbindung mit aktiviertem HTTP-Cache zu dem von mir beschriebenen fehlerhaften Verhalten geführt.

Insofern man, wie ich in dem Fall nur bestehende Templates bearbeitet, sollte man die Templates in der Frontend Theme Struktur anlegen und auf das extendsTemplate verzichten, da diese dann automatisch geladen werden. Also “frontend/listing/listing.tpl” beispielsweise.

Will man explizit ein neues/komplett eigenes Template verwenden sollte man die Funktion loadTemplate verwenden, darf in der, ich nenne sie mal custom.tpl dann nicht vergessen das entsprechende Template zu extenden, da sonst vom Rest der Seite nichts mehr geladen wird.

Ich hoffe ich habe das verständlich wiedergegeben. Dadurch tritt jedenfalls das mysteriöse Verhalten mit dem HTTP-Cache nicht mehr auf.&nbsp;Und nochmals riesen Dank an [@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl “Patrick Stahl”)‍ für seinen Einsatz.

Gruß

Daniel

---

<div class="post-metadata">

**Author:** ![elbsurfer](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@elbsurfer](https://forum.shopware.com/u/elbsurfer)\
**Post date:** [19. Juni 2018 um 12:46 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/26 "2018-06-19T12:46:43Z")

</div>

[@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl “Patrick Stahl”)‍

Ich verwende in meinem Plugin folgenden Code um im Backend ein Icon hinzuzufügen.

```
public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PostDispatch_Backend_Index' => 'addBackendTemplateDir',
        ];
    }

/**
     * @param \Enlight_Event_EventArgs $args
     */
    public function addBackendTemplateDir(\Enlight_Event_EventArgs $args) {
        try {
            /** @var \Enlight_Controller_Action $controller */
            $controller = $args->getSubject();
            $view = $controller->View();

            if ($view->hasTemplate()) {
                $view->extendsTemplate(
                    $this->getPath() . '/Resources/Views/backend/index/index.tpl'
                );
            }
        } catch (\Exception $e) {
        }
    }

```

Nun wurde mir folgender Fehler in 5.4.1 gemeldet:&nbsp;

```
MeinPlugin/Resources/Views/backend/index/index.tpl' not allowed by security setting

```

Ich kann diesen Fehler aktuell **nicht** in einer SW 5.4.1 Installation nicht reproduzieren. Was kann hier der Fehler sein - für mich sieht die index.tpl Registrierung im Backend richtig aus. Hättest Du oder jemand anderes einen Tipp?

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [20. Juni 2018 um 06:33 UTC](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703/27 "2018-06-20T06:33:22Z")

</div>

Hallo @elbsurfer‍,

dir fehlt schlichtweg das Hinzufügen deines Template-Ordners, also so:  
_$this-\>addTemplateDir($this-\>getPath() . ‚/Resources/Views/‘);_

Ich würde dir aber auch empfehlen deinen „views“ Ordner klein zu schreiben, aus Konsistenz-Gründen. 🙂

Gruß,  
Patrick&nbsp; ![Shopware](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "Shopware")

[Vorherige Seite](https://forum.shopware.com/t/plugin-uncaught-smartyexception-directory-not-allowed-by-security-setting/48703.md?page=1)
