自分のプラグインを使用してテンプレートfrontend/home/index.tpl
を拡張しようとしています。フォルダのリソース\ビュー\フロントエンド\ホーム\Shopware 5.2.20。プラグインを使用してテンプレートを拡張できません
<?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';
}
}
?>
があるdirrectoryコントローラでの私のコントローラ
MyPlugin.php \フロントエンド
public function preDispatch()
{
/** @var \Shopware\Components\Plugin $plugin */
$plugin = $this->get('kernel')->getPlugins()['TdevProductTab'];
$this->get('template')->addTemplateDir($plugin->getPath() . '/Resources/views/');
}
テンプレート:ここ
私のルート・ファイル
{extends file="parent:frontend/home/index.tpl"}
{block name='frontend_index_content'}
<div class="">Hello world!</div>
{$smarty.block.parent}
{/block}
私はofficial documentationを読んだ調査したプラグインの例plugins examples バックエンドにプラグインcrearキャッシュをインストール/再インストールした後、var/cache
にmanualyフォルダを削除した後。しかし、何も私を助けませんでした。
は、URL https://developers.shopware.com/developers-guide/shopware-5-plugin-update-guide/#template-extensionsからあなたが欲しいものを得るでしょう –
リンクは古いプラグインを示してい私は彼が新しいプラグインシステムを使用していると理解しています。 – Sadik
はい、私は新しいシステムを使用しています。 – Andrii