我正在创建一个shopware 5插件。我想在每个页面上的类别之后显示一些内容。我正在使用此代码执行此video中建议的任务,但未识别该事件。
这是我的代码
<?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}
任何帮助将不胜感激。
[我记得append
-Keywoard不应再在Shopware中使用。请改用{$smarty.block.parent}
。您还应该创建一个解释为here的EventSubscriber。
如果仍然无法解决,请检查您的缓存并激活插件