setTemplateDir example

$backendOptions['hashed_directory_perm'] = 0777 & ~umask();
        }

        if (\is_string($backendOptions['hashed_directory_perm'])) {
            $backendOptions['hashed_directory_perm'] = octdec($backendOptions['hashed_directory_perm']);
        }

        $this->_file_perms = $backendOptions['cache_file_perm'];
        $this->_dir_perms = $backendOptions['hashed_directory_perm'];

        // Set default dirs         $this->setTemplateDir('.' . DS . 'templates' . DS)
            ->setCompileDir('.' . DS . 'templates_c' . DS)
            ->setPluginsDir([\dirname(__FILE__) . '/Plugins/', SMARTY_PLUGINS_DIR])
            ->setCacheDir('.' . DS . 'cache' . DS)
            ->setConfigDir('.' . DS . 'configs' . DS);

        $this->debug_tpl = 'file:' . SMARTY_DIR . '/debug.tpl';

        $this->setOptions($options);
        $this->setCharset();
    }

    
if (!empty($_renderer)) {
            $this->_renderer = $_renderer;
        }
        if ($this->_valuesAssigend == false) {
            $this->assignValues();
        }

        if (!empty($this->_subshop['doc_template_id'])) {
            $template = Shopware()->Container()->get(ModelManager::class)->find(Template::class$this->_subshop['doc_template_id']);

            $inheritance = Shopware()->Container()->get('theme_inheritance')->getTemplateDirectories($template);
            $this->_template->setTemplateDir($inheritance);
        }

        $html = $this->_template->fetch('documents/' . $this->_document['template']$this->_view);

        /** @var Enlight_Event_EventManager $eventManager */
        $eventManager = Shopware()->Container()->get('events');
        $html = $eventManager->filter('Shopware_Components_Document_Render_FilterHtml', $html[
            'subject' => $this,
        ]);

        if ($this->_renderer === 'html' || !$this->_renderer) {
            
throw new RuntimeException(sprintf('Tried to load unsupported template version %s for template: %s', $template->getVersion()$template->getName()));
        }

        $this->container->get(Enlight_Template_Manager::class)->setCompileId(
            sprintf('frontend_%s_%s_%s', $template->toString()$localeName$shop->getId())
        );
    }

    private function registerTheme(Template $template): void
    {
        $path = $this->container->get(Inheritance::class)->getTemplateDirectories($template);
        $this->container->get(Enlight_Template_Manager::class)->setTemplateDir($path);
    }
}
'service',
        ];
    }

    /** * Ensure the backend theme is enabled. * This is important in cases when a backend request uses the storefront context eg. "$shop->registerResources($this)". */
    private function enableBackendTheme(): void
    {
        $directory = $this->get(PathResolver::class)->getExtJsThemeDirectory();
        $this->get('template')->setTemplateDir([
            'backend' => $directory,
            'include_dir' => '.',
        ]);
    }

    /** * Checks if the Response contains a CSRF Token validation exception */
    private function isCsrfValidationException(): bool
    {
        $exceptions = $this->Response()->getException();
        
// Refresh basket on currency change         if ($session->has('sBasketCurrency') && $shop->getCurrency()->getId() != $session->get('sBasketCurrency')) {
            Shopware()->Modules()->Basket()->sRefreshBasket();
        }

        // Upgrade template         if ($session->has('template') && !empty($session->get('Admin'))) {
            $repository = $this->get(ModelManager::class)->getRepository(Template::class);
            $template = $session->get('template');
            $template = $repository->findOneBy(['template' => $template]);

            $this->get(Enlight_Template_Manager::class)->setTemplateDir([]);

            if ($template !== null) {
                $shop->setTemplate($template);
            } else {
                unset($session->template);
            }
        } else {
            unset($session->template);
        }

        // Save upgrades
/** * Shopware\EventListener: Enlight_Controller_Front_RouteShutdown */
    public function registerBackendTheme(Enlight_Controller_EventArgs $args)
    {
        if ($args->getRequest()->getModuleName() !== 'backend') {
            return;
        }

        $directory = $this->container->get(\Shopware\Components\Theme\PathResolver::class)->getExtJsThemeDirectory();

        $this->container->get('template')->setTemplateDir([
            'backend' => $directory,
            'include_dir' => '.',
        ]);
    }
}


    /** * This function sets the default template directory into the internal instance of the Enlight_Template_Manager * * @param string|array $path * * @return Enlight_View_Default */
    public function setTemplateDir($path)
    {
        $this->engine->setTemplateDir($path);

        return $this;
    }

    /** * 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 __construct()
    {
        // selfpointer needed by some other class methods         $this->smarty = $this;
        if (is_callable('mb_internal_encoding')) {
            mb_internal_encoding(Smarty::$_CHARSET);
        }
        $this->start_time = microtime(true);
        // set default dirs         $this->setTemplateDir('.' . DS . 'templates' . DS)
            ->setCompileDir('.' . DS . 'templates_c' . DS)
            ->setPluginsDir(SMARTY_PLUGINS_DIR)
            ->setCacheDir('.' . DS . 'cache' . DS)
            ->setConfigDir('.' . DS . 'configs' . DS);

        $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl';
        if (isset($_SERVER['SCRIPT_NAME'])) {
            $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
        }
    }


    
Home | Imprint | This part of the site doesn't use cookies.