I'm trying to extend template frontend/home/index.tpl
via own plugin.
Here my root file:
<?php
namespace TdevExtend;
use Shopware\Components\Plugin;
class TdevExtend extends Plugin
{
public static function getSubscribedEvents(){
return [
'Enlight_Controller_Dispatcher_ControllerPath_Frontend_MyPlugin' =>
'onDetailPostDispatch'
];
}
public function onDetailPostDispatch(\Enlight_Event_EventArgs $args)
{
$this->container->get('template')->addTemplateDir(
$this->getPath() . '/Resources/views/'
);
return __DIR__ . '/Controllers/Frontend/MyPlugin.php';
}
}
?>
Here are my Controller MyPlugin.php in dirrectory Controllers\Frontend
public function preDispatch()
{
/** @var \Shopware\Components\Plugin $plugin */
$plugin = $this->get('kernel')->getPlugins()['TdevProductTab'];
$this->get('template')->addTemplateDir($plugin->getPath() . '/Resources/views/');
}
And template in folder Resources\views\frontend\home\
{extends file="parent:frontend/home/index.tpl"}
{block name='frontend_index_content'}
<div class="">Hello world!</div>
{$smarty.block.parent}
{/block}
I have read official documentation and researched plugins examples plugins examples
After installing/reinstalling plugin crear cache on backend and delete manualy folder in var/cache
. But nothing has helped me.