Shopware 5: Plugin does not overwrite template view












0














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



<?php

namespace PrOlgaStartup;

use ShopwareComponentsPlugin;

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!!! :-)










share|improve this question



























    0














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



    <?php

    namespace PrOlgaStartup;

    use ShopwareComponentsPlugin;

    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!!! :-)










    share|improve this question

























      0












      0








      0







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



      <?php

      namespace PrOlgaStartup;

      use ShopwareComponentsPlugin;

      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!!! :-)










      share|improve this question













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



      <?php

      namespace PrOlgaStartup;

      use ShopwareComponentsPlugin;

      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!!! :-)







      php shopware






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 16:53









      pr-olga

      162




      162
























          2 Answers
          2






          active

          oldest

          votes


















          0














          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/'
          );
          }





          share|improve this answer





















          • Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
            – pr-olga
            Nov 23 '18 at 14:17










          • I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
            – pr-olga
            Nov 23 '18 at 14:25










          • What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
            – Rotfuchs
            Nov 28 '18 at 6:28












          • Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
            – pr-olga
            Nov 29 '18 at 8:13



















          0














          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.






          share|improve this answer





















          • Consider marking this as the best answer, if this solved your problem.
            – mbrandau
            Dec 27 '18 at 10:45











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416998%2fshopware-5-plugin-does-not-overwrite-template-view%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          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/'
          );
          }





          share|improve this answer





















          • Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
            – pr-olga
            Nov 23 '18 at 14:17










          • I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
            – pr-olga
            Nov 23 '18 at 14:25










          • What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
            – Rotfuchs
            Nov 28 '18 at 6:28












          • Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
            – pr-olga
            Nov 29 '18 at 8:13
















          0














          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/'
          );
          }





          share|improve this answer





















          • Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
            – pr-olga
            Nov 23 '18 at 14:17










          • I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
            – pr-olga
            Nov 23 '18 at 14:25










          • What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
            – Rotfuchs
            Nov 28 '18 at 6:28












          • Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
            – pr-olga
            Nov 29 '18 at 8:13














          0












          0








          0






          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/'
          );
          }





          share|improve this answer












          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/'
          );
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 5:53









          Rotfuchs

          51318




          51318












          • Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
            – pr-olga
            Nov 23 '18 at 14:17










          • I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
            – pr-olga
            Nov 23 '18 at 14:25










          • What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
            – Rotfuchs
            Nov 28 '18 at 6:28












          • Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
            – pr-olga
            Nov 29 '18 at 8:13


















          • Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
            – pr-olga
            Nov 23 '18 at 14:17










          • I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
            – pr-olga
            Nov 23 '18 at 14:25










          • What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
            – Rotfuchs
            Nov 28 '18 at 6:28












          • Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
            – pr-olga
            Nov 29 '18 at 8:13
















          Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
          – pr-olga
          Nov 23 '18 at 14:17




          Hi Rotfuchs, thank you for the answer! Unfortunately, it has no effect... I mean am I only person who has this problem!?
          – pr-olga
          Nov 23 '18 at 14:17












          I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
          – pr-olga
          Nov 23 '18 at 14:25




          I mean I do everything like here (begin at 7:00) (modulo PreDispatch), it does not work...
          – pr-olga
          Nov 23 '18 at 14:25












          What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
          – Rotfuchs
          Nov 28 '18 at 6:28






          What exactly do you wan't to overwrite? The ajax-search has another template than the search-result page. Perhaps a Screenshot will help. You should consider the hint with "injectbeforeplugins" too, because an overwrite via plugin is only possible, when there is no theme with injectbeforeplugins = false overwriting the same block.
          – Rotfuchs
          Nov 28 '18 at 6:28














          Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
          – pr-olga
          Nov 29 '18 at 8:13




          Thank you, Rotfuchs, for the answer! I have already found the solution: see the answer below :-)
          – pr-olga
          Nov 29 '18 at 8:13













          0














          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.






          share|improve this answer





















          • Consider marking this as the best answer, if this solved your problem.
            – mbrandau
            Dec 27 '18 at 10:45
















          0














          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.






          share|improve this answer





















          • Consider marking this as the best answer, if this solved your problem.
            – mbrandau
            Dec 27 '18 at 10:45














          0












          0








          0






          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 14:27









          pr-olga

          162




          162












          • Consider marking this as the best answer, if this solved your problem.
            – mbrandau
            Dec 27 '18 at 10:45


















          • Consider marking this as the best answer, if this solved your problem.
            – mbrandau
            Dec 27 '18 at 10:45
















          Consider marking this as the best answer, if this solved your problem.
          – mbrandau
          Dec 27 '18 at 10:45




          Consider marking this as the best answer, if this solved your problem.
          – mbrandau
          Dec 27 '18 at 10:45


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416998%2fshopware-5-plugin-does-not-overwrite-template-view%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'