I am searching for a way to show a message box, in case the page has a 301 or 302 redirect in the header.
I am new to plug-ins in Shopware and Symphony, so maybe somebody can tell me how and where I can trigger the function that shows the message in the twig file?
You can use Symfony's flash messages to add danger/warning/info/success messages and such. By extending the abstract class with your storefront controller you'll have access to the method
addFlash. Thebase.html.twigtemplate, which you will likely want to extend with your custom template, already has markup in place for displaying the flash messages at the top of the page. So all you would have to do is add the message in your controller and it should show up.As a simplified example: