addTemplateDir example

if (!file_exists($path)) {
            throw new Enlight_Exception(sprintf('Controller "%s" can\'t load failure', $controller));
        }

        // register plugin model directory         if (file_exists($this->Path() . 'Models')) {
            $this->registerCustomModels();
        }

        // register plugin views directory         if (file_exists($this->Path() . 'Views')) {
            Shopware()->Template()->addTemplateDir(
                $this->Path() . 'Views/'
            );
        }

        // register plugin snippet directory         if (file_exists($this->Path() . 'Snippets')) {
            Shopware()->Snippets()->addConfigDir(
                $this->Path() . 'Snippets/'
            );
        }

        
return $dirs;
    }

    /** * Add View path to Smarty * * @return void */
    public function addPaths(Enlight_Event_EventArgs $arguments)
    {
        $this->Application()->Template()->addTemplateDir(
            $this->Path() . 'Views/responsive/',
            'payment',
            Enlight_Template_Manager::POSITION_APPEND
        );
    }

    /** * Called when the BackendOrderPostDispatch Event is triggered * * @return void */
    
'zipCode' => $data['zipcode'],
            'bankName' => $data['bank_name'],
            'iban' => $data['iban'],
            'bic' => $data['bic'],
        ]);
        Shopware()->Template()->assign('config', [
            'sepaCompany' => Shopware()->Config()->get('sepaCompany'),
            'sepaHeaderText' => Shopware()->Config()->get('sepaHeaderText'),
            'sepaSellerId' => Shopware()->Config()->get('sepaSellerId'),
        ]);

        Shopware()->Template()->addTemplateDir(__DIR__ . '/../Views/');
        $data = Shopware()->Template()->fetch('frontend/plugins/sepa/email.tpl');

        /** @var array<string, string> $mpdfConfig */
        $mpdfConfig = Shopware()->Container()->getParameter('shopware.mpdf.defaultConfig');
        $mpdf = new Mpdf($mpdfConfig);
        $mpdf->WriteHTML($data);
        $pdfFileContent = $mpdf->Output('', 'S');

        if ($pdfFileContent === false) {
            throw new Enlight_Exception('Could not generate SEPA attachment file');
        }

        
public function registerBackendTemplates(Enlight_Event_EventArgs $args)
    {
        /** @var Enlight_View_Default $view */
        $view = $args->get('subject')->View();

        $templateDir = $this->path . '/Resources/views/emotion_components/';

        if (!file_exists($templateDir)) {
            return;
        }

        $view->addTemplateDir($templateDir);
        $backendPath = $templateDir . 'backend/';
        if (!file_exists($backendPath)) {
            return;
        }

        $directoryIterator = new DirectoryIterator($backendPath);
        $regex = new RegexIterator($directoryIterator, '/^.+\.js$/i', RecursiveRegexIterator::GET_MATCH);
        foreach ($regex as $file) {
            $path = 'backend/' . $file[0];
            $view->extendsBlock(
                'backend/Emotion/app',
                

    public function addTemplateDir($template_dir$key = null, $position = null)
    {
        if (\is_array($template_dir)) {
            foreach ($template_dir as $k => $v) {
                $this->addTemplateDir($v, \is_int($k) ? null : $k);
            }

            return $this;
        }
        $_template_dir = $this->getTemplateDir();
        if ($position === self::POSITION_PREPEND) {
            if ($key === null) {
                array_unshift($_template_dir$template_dir);
            } else {
                $_template_dir = array_merge([$key => $template_dir]$_template_dir);
                $_template_dir[$key] = $template_dir;
            }

    }

    /** * When index backend module was loaded, add our snippet- and template-directory * Also extend the template * * @return void */
    public function onBackendIndexPostDispatch(Enlight_Controller_ActionEventArgs $args)
    {
        $args->getSubject()->View()->addTemplateDir(
            __DIR__ . '/Views/'
        );

        // if the controller action name equals "load" we inject our update check         if ($args->getRequest()->getActionName() === 'load') {
            $args->getSubject()->View()->extendsTemplate(
                'backend/index/view/swag_update_menu.js'
            );
        }
    }

    
$view = $args->getSubject()->View();
        $parent = (int) $this->get('shop')->get('parentID');
        $categoryId = (int) $args->getRequest()->getParam('sCategory', $parent);

        $menu = $this->getAdvancedMenu($parent$categoryId(int) $config->get('levels'));

        $view->assign('sAdvancedMenu', $menu);
        $view->assign('columnAmount', $config->get('columnAmount'));

        $view->assign('hoverDelay', $config->get('hoverDelay'));

        $view->addTemplateDir($this->Path() . 'Views');
    }

    /** * Returns the complete menu with category path. * * @param int $category * @param int $activeCategoryId * @param int $depth * * @return array<array<string, mixed>> */
    


    public function onRegisterControllerTemplate(Enlight_Controller_ActionEventArgs $args): void
    {
        $viewsDirectory = $this->pluginPath . '/Resources/views';

        $controller = $args->getSubject();

        try {
            $view = $controller->View();
            if ($view !== null) {
                $view->Template()->Engine()->addTemplateDir($viewsDirectory);
            }
        } catch (Enlight_Exception $ignored) {
        }
    }

    /** * @param string $baseDir resource base directory * @param string $type `css` or `js` * * @return array<string> */
    
/** * This function adds a template directory into the internal instance of the Enlight_Template_Manager * * @param string|string $templateDir * @param string|null $key * * @return Enlight_View_Default */
    public function addTemplateDir($templateDir$key = null)
    {
        $this->engine->addTemplateDir($templateDir$key);

        return $this;
    }

    /** * Sets the current template instance into the internal property. * * @return Enlight_View_Default */
    public function setTemplate(?Enlight_Template_Default $template = null)
    {
        

    public function init()
    {
        if (!$this->Request()->getActionName()
            || \in_array($this->Request()->getActionName()['index', 'load'])
        ) {
            $this->View()->addTemplateDir('.');
            $this->Front()->Plugins()->ScriptRenderer()->setRender();
            Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        } else {
            parent::init();
        }
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
Home | Imprint | This part of the site doesn't use cookies.