템플릿을 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
에 수동 폴더를 삭제하십시오. 그러나 아무것도 나를 도왔습니다.
당신은 –
링크는 기존의 플러그인을 보여줍니다 당신이 URL https://developers.shopware.com/developers-guide/shopware-5-plugin-update-guide/#template-extensions에서 원하는 것을 얻을 것이다 시스템에서 사용할 수 있지만, 내가 아는 한 그는 새로운 플러그인 시스템을 사용하고있다. – Sadik
네, 새로운 시스템을 사용하고 있습니다. – Andrii