# Plugin priority

**URL:** <https://forum.shopware.com/t/plugin-priority/34768>\
**Category:** International (English Only)\
**Tags:** programming\
**Created:** [24. Februar 2016 um 12:58 UTC](https://forum.shopware.com/t/plugin-priority/34768 "2016-02-24T12:58:51Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [24. Februar 2016 um 12:58 UTC](https://forum.shopware.com/t/plugin-priority/34768/1 "2016-02-24T12:58:51Z")

</div>

Hi all

```
 I try to develop new plugin to change footer. And when I install it on dev server it works. But on production not. How I can set priority to plugin? I mean firstly use footer from my plugin and only then from another plugins/themes
```

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [24. Februar 2016 um 14:56 UTC](https://forum.shopware.com/t/plugin-priority/34768/2 "2016-02-24T14:56:52Z")

</div>

It is like

1. Core

2. Plug-Ins

3. Themes

This is how shopware inherits in SW5.

Now you have 2 options to overwrite the default inheritance:

1. Tell the theme via

that it should load before the plug-ins

1. register your functions to the subscribeEvents of your plug-ins with an higher position as the other plug-ins or themes via a third parameter

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [25. Februar 2016 um 08:04 UTC](https://forum.shopware.com/t/plugin-priority/34768/3 "2016-02-25T08:04:34Z")

</div>

So, I wrote

> &nbsp; &nbsp;public function install()  
> &nbsp; &nbsp; {  
> &nbsp; &nbsp; &nbsp; &nbsp; $this-\>subscribeEvent(  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‚Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend‘,  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‚onFrontendPostDispatch‘,
> 
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0  
> &nbsp; &nbsp; &nbsp; &nbsp; );
> 
> &nbsp; &nbsp; &nbsp; &nbsp; return true;  
> &nbsp; &nbsp; }

&nbsp;

and see nothing. Can you help me?

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [25. Februar 2016 um 08:29 UTC](https://forum.shopware.com/t/plugin-priority/34768/4 "2016-02-25T08:29:36Z")

</div>

Well, Zero is a pretty low value for a higher position 😉

Try _PHP\_INT\_MAX_

_and if this works try a more feasible value._

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [25. Februar 2016 um 08:38 UTC](https://forum.shopware.com/t/plugin-priority/34768/5 "2016-02-25T08:38:11Z")

</div>

Ohh, its not work too.

Maybe exists some way to known what tpl files shopware use to render page? Like debug or something else

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [25. Februar 2016 um 15:39 UTC](https://forum.shopware.com/t/plugin-priority/34768/6 "2016-02-25T15:39:38Z")

</div>

anybody can’t help? (

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [26. Februar 2016 um 08:23 UTC](https://forum.shopware.com/t/plugin-priority/34768/7 "2016-02-26T08:23:47Z")

</div>

Ok, another idea came to my mind:

Since this is a frontend-extension i am assuming you are appending or prepending some smarty blocks.

There is a known bug that two Plug-Ins appending/prepending the same smarty block won’t both append/prepend. So instead of  
&nbsp;

```
{block name='x' append}

//my code

{/block}

```

use  
&nbsp;

```
{block name='x'}

{$smarty.block.parent}

//my code

{/block}

```

(for prepend operation just swap //my code with {$smarty.block.parent}

&nbsp;

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [26. Februar 2016 um 08:46 UTC](https://forum.shopware.com/t/plugin-priority/34768/8 "2016-02-26T08:46:37Z")

</div>

Hi

it does not help(

my code is&nbsp;

```
{extends file="parent:frontend/index/footer.tpl"}

{block name="frontend_index_shopware_footer_copyright"}
{$smarty.block.parent}

test
{/block}

```

But I wonder about right way to tpl file.

In plugin I use Views/frontend/index/footer.tpl

Maybe exists some way to known what tpl files shopware use to render page? Like debug or something else

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [26. Februar 2016 um 08:59 UTC](https://forum.shopware.com/t/plugin-priority/34768/9 "2016-02-26T08:59:25Z")

</div>

please post your onFrontendPostDispatch

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [26. Februar 2016 um 09:02 UTC](https://forum.shopware.com/t/plugin-priority/34768/10 "2016-02-26T09:02:06Z")

</div>

> [@steinsoftware schrieb:](https://forum.shopware.com/profile/17116/steinsoftware "steinsoftware")
> 
> please post your onFrontendPostDispatch

Sorry, can you explain? I new shopware plugin developer and don’t understand what do you mind&nbsp;

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [26. Februar 2016 um 12:57 UTC](https://forum.shopware.com/t/plugin-priority/34768/11 "2016-02-26T12:57:37Z")

</div>

> So, I wrote
> 
> &nbsp; &nbsp;public function install()  
> &nbsp; &nbsp; {  
> &nbsp; &nbsp; &nbsp; &nbsp; $this-\>subscribeEvent(  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‚Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend‘,  
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‚onFrontendPostDispatch‘,
> 
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0  
> &nbsp; &nbsp; &nbsp; &nbsp; );
> 
> &nbsp; &nbsp; &nbsp; &nbsp; return true;  
> &nbsp; &nbsp; }
> 
> &nbsp;
> 
> and see nothing. Can you help me?

&nbsp;

So you registered your own function onFrontendPostDispatch.

If you don’t have such function you should start over here:

> **[Developer Guides](https://developers.shopware.com/developers-guide/)**
>
> Developer Guides

&nbsp;

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [26. Februar 2016 um 13:04 UTC](https://forum.shopware.com/t/plugin-priority/34768/12 "2016-02-26T13:04:36Z")

</div>

I have such function

```
    public function onFrontendPostDispatch(Enlight_Event_EventArgs $args)
    {
        /** @var \Enlight_Controller_Action $controller */
        $controller = $args->get('subject');
        $view = $controller->View();

        $view->addTemplateDir(
            __DIR__. '/Views'
        );
    }

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [29. Februar 2016 um 08:06 UTC](https://forum.shopware.com/t/plugin-priority/34768/13 "2016-02-29T08:06:33Z")

</div>

Any others idea?(

---

<div class="post-metadata">

**Author:** ![Shopwareianer](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Shopwareianer](https://forum.shopware.com/u/Shopwareianer)\
**Post date:** [29. Februar 2016 um 11:26 UTC](https://forum.shopware.com/t/plugin-priority/34768/14 "2016-02-29T11:26:06Z")

</div>

@Maksim‍ You may have a look at this very simple Plugin which changes&nbsp;the newsletter section in the footer:&nbsp;[https://github.com/hostianer/HostiReplaceNewsletter](https://github.com/hostianer/HostiReplaceNewsletter)

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://forum.shopware.com/u/Maksim)\
**Post date:** [29. Februar 2016 um 18:01 UTC](https://forum.shopware.com/t/plugin-priority/34768/15 "2016-02-29T18:01:21Z")

</div>

It does not help because shopware when renredering page&nbsp;use tpl files in&nbsp;unknown order. I need to know what tpl files uses for render page

---

<div class="post-metadata">

**Author:** ![DanielNogel](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@DanielNogel](https://forum.shopware.com/u/DanielNogel)\
**Post date:** [29. Februar 2016 um 18:14 UTC](https://forum.shopware.com/t/plugin-priority/34768/16 "2016-02-29T18:14:12Z")

</div>

Hi,

the general hierarchy can be accessed with this command:&nbsp;

```
 &nbsp;

Shopware()->Template()->getTemplateDir()

```

It will print out something like this:

```
Array
(
    [0] => /var/www/html/52/engine/Shopware/Plugins/Local/Frontend/SwagPromotion/Views/
    [1] => /var/www/html/52/themes/Frontend/Responsive/
    [2] => /var/www/html/52/themes/Frontend/Bare/
)

```

So in my case, it will look up a given template file in the order SwagPromotion-Plugin, Responsive-Theme, Bare-Theme. If you have a custom theme in place, the hierarchy will look like this:

```
Array
(
    [0] => /var/www/html/52/themes/Frontend/CustomTheme/
    [1] => /var/www/html/52/engine/Shopware/Plugins/Local/Frontend/SwagPromotion/Views/
    [2] => /var/www/html/52/themes/Frontend/Responsive/
    [3] => /var/www/html/52/themes/Frontend/Bare/
)

```

So in this case, the custom theme will extend / overwrite my plugin’s template.&nbsp;

Daniel

---

<div class="post-metadata">

**Author:** ![Shopwareianer](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Shopwareianer](https://forum.shopware.com/u/Shopwareianer)\
**Post date:** [29. Februar 2016 um 18:15 UTC](https://forum.shopware.com/t/plugin-priority/34768/17 "2016-02-29T18:15:17Z")

</div>

@Maksim‍ Which shopware version have you installed?

You may have a look at&nbsp;[Getting started with Smarty](https://developers.shopware.com/designers-guide/smarty/#inheritance-and-plugin-templates)

This theme&nbsp;configuration property has come with version 5.1.2:&nbsp;[SW-12782 - Add theme config property to configure inheritance position · shopware/shopware@163860e · GitHub](https://github.com/shopware/shopware/commit/163860e8b789f8c0f0aa40ddc1661c0abcd7cada)

You can change the var in your Theme.php to _true_ or _false_:&nbsp;[shopware/Theme.php at 5.1 · shopware/shopware · GitHub](https://github.com/shopware/shopware/blob/5.1/themes/Frontend/Responsive/Theme.php#L43)
