MHotaitMHotait MemberComments: 19 Received thanks: 0 Member since: May 2018

hallo,

ich probiere jetzt mein erstes plugin einzubauen. Ich habe aber ein Fehler so das die custom theme template ist angezeigt statt meine plugin template ? wie mache ich es so das die template von plugin angezeigt ist ? danke im voraus

 

MohtGeschenkVerpackung.php

<?php

namespace MohtGeschenkVerpackung;

use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\DeactivateContext;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UninstallContext;


class MohtGeschenkVerpackung extends \Shopware\Components\Plugin
{
    public function install(InstallContext $context)
    {
        $context->scheduleClearCache($this->getCacheArray());
        parent::install($context);
 
    }
 
    public function uninstall(UninstallContext $context)
    {
        $context->scheduleClearCache($this->getCacheArray());
        parent::uninstall($context);
    }
 
    public function activate(ActivateContext $context)
    {
        $context->scheduleClearCache($this->getCacheArray());
        parent::install($context);
    }
 
    public function deactivate(DeactivateContext $context)
    {
        $context->scheduleClearCache($this->getCacheArray());
        parent::install($context);
    }
 
 
    /**
     * Get caches to clear
     *
     * @return array
     */
    private function getCacheArray()
    {
        return [
            InstallContext::CACHE_TAG_CONFIG,
            InstallContext::CACHE_TAG_HTTP
        ];
    }
}

Subscriber/TemplateRegistration.php

<?php

namespace MohtGeschenkVerpackung\Subscriber;

use Enlight\Event\SubscriberInterface;

class TemplateRegistration implements SubscriberInterface
{
    /**
     * @var string
     */
    private $pluginDirectory;

    /**
     * @var \Enlight_Template_Manager
     */
    private $templateManager;

    /**
     * @param $pluginDirectory
     * @param \Enlight_Template_Manager $templateManager
     */
    public function __construct($pluginDirectory, \Enlight_Template_Manager $templateManager)
    {
        $this->pluginDirectory = $pluginDirectory;
        $this->templateManager = $templateManager;
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PreDispatch' => 'onPreDispatch'
        ];
    }

    public function onPreDispatch()
    {
        $this->templateManager->addTemplateDir($this->pluginDirectory . '/Resources/views');
    }
}

und Resources/service.xml

<container xmlns="http://symfony.com/schema/dic/services";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">;

    <services>
        <!-- Register TemplateRegistration subscriber -->
        <service id="moht_geschenk_verpackung.subscriber.template_registration" class="MohtGeschenkVerpackung\Subscriber\TemplateRegistration">
            <argument>%moht_geschenk_verpackung.plugin_dir%</argument>
            <argument type="service" id="template"/>
            <tag name="shopware.event_subscriber"/>
        </service>
    </services>
</container>

die template habe ich unter Resources/views/checkout/cart_footer.tpl

{extends file="parent:frontend/checkout/cart_footer.tpl"}

{* Add product using the sku *}
{block name='frontend_checkout_cart_footer_add_product'}
    aaaaaaaaa
{/block}

{block name='frontend_checkout_cart_footer_element'}
    vvvvv
{/block}

was fählt mir noch ? 

Danke 

Sign In or Register to comment.