1
votes

Plugin has to overwrite the search template in Theme but it does not. It contains following files: PrOlgaStartup/PrOlgaStartup.php

<?php

namespace PrOlgaStartup;

use Shopware\Components\Plugin;

class PrOlgaStartup extends Plugin
{

 public static function getSubscribedEvents()
{
     return [
        'Enlight_Controller_Action_PostDispatchSecure_Frontend' => 'extendsFrontend'
    ];
}

public function extendsFrontend(\Enlight_Controller_ActionEventArgs $args)
{
    /** @var \Enlight_Controller_Action $controller */
    // Breadrcrumbs must dissapear
    $subject = $args->getSubject();
    $subject->View()->addTemplateDir(__DIR__ . '/Resources/views');

}
}

PrOlgaStartup/Resources/views/frontend/index/search.tpl

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

{block name="frontend_index_search_container"}
    Hello World!
{/block}

Some Notes

  1. Tested in vagrant and bitnami
  2. Theme is extended by protected $injectBeforePlugins = true;
  3. Theme does not contain custom search.tpl
  4. Cache has been cleared
  5. This solution does not work as well

Thank you very much in advance!!! :-)

2

2 Answers

1
votes

The only way to make it work (i.e. include plugin templates) is:

  1. Put the development environment into vagrant (I work on Windows OS)
  2. Put variable protected $injectBeforePlugins = true; into Theme.php

The injection of this variable does not make any effect in bitnami at all, and the combination above seems to be missed in my tests. Why this is the case, it is not clear to me (now). Presumably, the only answer of the day is this, i.e. it depends on your OS and/or on your virtual machine.

0
votes

Try to use the "new" way to register a template:

public function extendsFrontend(\Enlight_Event_EventArgs $args)
{
    $this->container->get('Template')->addTemplateDir(
        $this->getPath() . '/Resources/views/'
    );
}