How overwrite default template smarty file from shopware tpl files by plugin?

Hi Guys!

I am working with Shopware learning course in Udemy [link], and i got stuck in the end. The stuck is at the last chapter Subscriber methods and global events. Currently im struggling with  hide default search by shouting the event and change the default template directory. I follow step by step and still doesn’t know how i can achieve the same efect as the course trainer. Could you guys help me? 

I am using:

Shopware 5.5.8
Windows 10 Professional OS
XAMP with 7.2 PHP version. 

Github link to code with plugin: 
[Link]

Here is the code for my TkStartup plugin:

 'onPreDispatchTemplateRegistration'];
    }

    public function onPreDispatchTemplateRegistration(\Enlight_Event_EventArgs $args)
    {
        $controller = $args->getSubject();
        $templateDir = __DIR__. '/Resources/views';

        $controller->View()->addTemplateDir($templateDir);
    }
}

 

And here is my catalog structures:

custom/Plugins/TkStartup – folder with my plugin
and there i have  Resources/views/frontend/index/search.tpl   

And i have Controller like that:
Routing Demonstration.php which i use to show my custom content of webpage.

The main goal is to hide search form input whenever it is hit to routingDemonstration controller.

Smarty code: 

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

{block name='frontend_index_search_container'}
 Nothing to search in here! 
{/block}

      

The path should be Resources/views/frontend/index/search.tpl  

1 „Gefällt mir“

@Shopwareianer schrieb:

The path should be Resources/views/frontend/index/search.tpl  

I change it to lower case but it still doesn’t resolve the issue. 

Hi guys i managed to create working solution. All i had to do was to use vagrant to create my Ubuntu OS instance box where i deployed it. I used official shopware documentation in here:

https://developers.shopware.com/developers-guide/vagrant-phpstorm/

So i managed it to work properly but I dont know why Windows it is not working the same way as it should work on Linux based systems.

I read about some stackoverflow topics that on WINDOWS OS we can’t this kind of things is it a bug ? Maybe I should report it ? 

Here is a link to those two topics on stack:

https://stackoverflow.com/questions/53416998/shopware-5-plugin-does-not-overwrite-template-view

https://stackoverflow.com/questions/42819695/shopware-5-2-20-cannot-extend-template-via-plugin#comment72771135_42826390

Oh yeah … Shopware is having some issues with Windows and Linux is also recommended.

Maybe you should also take a look at vscode remote / ssh which was released a few weeks ago. So you can run your dev enviorement on a linux machine / server and connect to the server with vscode or even with a docker container: https://code.visualstudio.com/docs/remote/remote-overview

So you don’t need to run a VM on your machine.

1 „Gefällt mir“

Hello,

Is it possible in the near future to get this thing works on windows? I spent 2 days with a headache why my codes doesn’t working on my dev machine before finding this thread…
I had very good impressions with Shopware but seems its getting away… :frowning: