Reputation: 358
I am creating a shopware 5 plugin. I want to display something after the categories on every page. I am using this code to do my task as suggested in this video, but the event is not getting recognized.
Here is my code
<?php
namespace MyPlugin;
use Shopware\Components\Plugin;
class MyPlugin extends Plugin{
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Action_PreDispatch_Frontend' => 'onPreDispatch'
];
}
public function onPreDispatch(\Enlight_Event_EventArgs $args)
{
$controller = $args->getSubject();
$view = $controller->View();
$view->addTemplateDir(__DIR__.'/Resources/views');
}
}
frontend/index/index.tpl
{extends file="parent:frontend/index/index.tpl"}
{block name="frontend_index_navigation_categories_top" append}
<div>my items here</div>
{/block}
Any help would be much appreciated.
Upvotes: 0
Views: 306
Reputation: 131
As I remember the append
-Keywoard shouldn't be used in Shopware anymore. Use {$smarty.block.parent}
instead.
Also you should create an EventSubscriber explained here.
If this still doesn't work please check your cache and that the plugin is activated
Upvotes: 1