templateExists example

$this->View()->assign([
            'sBanner' => Shopware()->Modules()->Marketing()->sBanner($requestCategoryId),
            'sBreadcrumb' => $this->getBreadcrumb($requestCategoryId),
            'sCategoryContent' => $categoryContent,
            'activeFilterGroup' => $request->getQuery('sFilterGroup'),
            'ajaxCountUrlParams' => ['sCategory' => $categoryContent['id']],
            'params' => $request->getParams(),
        ]);

        if (!empty($categoryContent['template'])) {
            if ($this->View()->templateExists('frontend/listing/' . $categoryContent['template'])) {
                $vars = $this->View()->getAssign();
                $this->View()->loadTemplate('frontend/listing/' . $categoryContent['template']);
                $this->View()->assign($vars);
            } else {
                $this->get('corelogger')->error(
                    'Missing category template detected. Please correct the template for category "' . $categoryContent['name'] . '".',
                    [
                        'uri' => $this->Request()->getRequestUri(),
                        'categoryId' => $requestCategoryId,
                        'categoryName' => $categoryContent['name'],
                    ]
                );
if (!empty($staticPage['html'])) {
            $this->View()->assign('sContent', $staticPage['html']);
        }

        $this->View()->assign('sCustomPage', $staticPage);

        for ($i = 1; $i <= 3; ++$i) {
            if (empty($staticPage['tpl' . $i . 'variable']) || empty($staticPage['tpl' . $i . 'path'])) {
                continue;
            }
            if (!$this->View()->templateExists($staticPage['tpl' . $i . 'path'])) {
                continue;
            }
            $this->View()->assign(
                $staticPage['tpl' . $i . 'variable'],
                $this->View()->fetch($staticPage['tpl' . $i . 'path'])
            );
        }
    }
}
parent::postDispatch();

        $this->View()->assign('sType', $this->type);
        $this->View()->assign('sFields', $this->getFields());
        $this->View()->assign('sAction', $this->Request()->getActionName());
        $this->View()->assign('sTitleKey', $this->type->getViewTitleFieldName());
        $this->View()->assign('sMetaTitleKey', $this->type->getViewMetaTitleFieldName());
        $this->View()->assign('sDescriptionKey', $this->type->getViewDescriptionFieldName());
        $this->View()->assign('sMetaDescriptionKey', $this->type->getViewMetaDescriptionFieldName());
        $this->View()->assign('sImageKey', $this->type->getViewImageFieldName());

        if (!$this->View()->templateExists($this->View()->Template()->template_resource)) {
            if ($this->Request()->getActionName() === 'index') {
                $this->View()->Template()->template_resource = 'frontend/content_type/index.tpl';

                return;
            }

            $this->View()->Template()->template_resource = 'frontend/content_type/detail.tpl';
        }
    }

    public function getBreadcrumb(?array $item = null): array
    {


    /** * Checks if the Enlight_Template_Manager stored the given template. * * @param string $template_name * * @return bool */
    public function templateExists($template_name)
    {
        return $this->engine->templateExists($template_name);
    }

    /** * Assigns a specified value to the template. * If no cache or scope given, the default settings for this property will be used. * * @param array|string $spec * @param mixed|null $value * @param bool|null $nocache * @param int|null $scope * * @return \Enlight_View|\Enlight_View_Default */
return $this->clearCompiledTemplate($tpl_file$compile_id$exp_time);
    }

    /** * Checks whether requested template exists. * * @param string $tpl_file * @return boolean */
    public function template_exists($tpl_file)
    {
        return $this->templateExists($tpl_file);
    }

    /** * Returns an array containing template variables * * @param string $name * @return array */
    public function get_template_vars($name=null)
    {
        return $this->getTemplateVars($name);
    }
Home | Imprint | This part of the site doesn't use cookies.