/** * Parse the template * @return string */ public function generate() { if (TL_MODE == 'BE') { // create new backend template $objTemplate = new \BackendTemplate('be_include'); // get the article $objArticle = \ArticleModel::findByPk($this->articleAlias); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('articleAlias', $this->articleAlias, $this->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } // add CSS $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; // return info + content return $objTemplate->parse() . parent::generate(); } // return content only return parent::generate(); }
/** * Parse the template * @return string */ public function generate() { if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start > 0 && $this->start > time() || $this->stop > 0 && $this->stop < time())) { return ''; } if ($this->arrData['space'][0] != '') { $this->arrStyle[] = 'margin-top:' . $this->arrData['space'][0] . 'px;'; } if ($this->arrData['space'][1] != '') { $this->arrStyle[] = 'margin-bottom:' . $this->arrData['space'][1] . 'px;'; } $this->Template = new \FrontendTemplate($this->strTemplate); $this->Template->setData($this->arrData); $this->compile(); $this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : ''; $this->Template->cssID = $this->cssID[0] != '' ? ' id="' . $this->cssID[0] . '"' : ''; $this->Template->class = trim('ce_' . $this->type . ' ' . $this->cssID[1]); if ($this->Template->headline == '') { $this->Template->headline = $this->headline; } if ($this->Template->hl == '') { $this->Template->hl = $this->hl; } // add include information in backend if (TL_MODE == 'BE') { // get include breadcrumbs that reference this content element $includes = \IncludeInfoHelper::getIncludes(array("cteAlias = ? AND type = 'alias'"), array($this->id), $this->id); // check for result if (count($includes) > 0) { // create new backend template $objTemplate = new \BackendTemplate('be_include'); // set include breadcrumbs $objTemplate->includes = $includes; // add CSS $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; // return parsed template with include info return $objTemplate->parse() . $this->Template->parse(); } } return $this->Template->parse(); }
/** * Generate the widget and return it as string * @return string */ public function generate() { // create new include template $objTemplate = new \BackendTemplate('be_include'); // get the active record $activeRecord = $this->arrConfiguration['activeRecord']; // get the type $type = $activeRecord->type; // get the table $table = $this->arrConfiguration['strTable']; // depending on type if ($type == 'alias') { // get the element $objElement = \ContentModel::findByPk($activeRecord->cteAlias); if ($objElement === null) { return ''; } // get the parent article $objArticle = \ArticleModel::findByPk($objElement->pid); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('cteAlias', $activeRecord->cteAlias, $activeRecord->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } } elseif ($type == 'article') { // get the article $objArticle = \ArticleModel::findByPk($activeRecord->articleAlias); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('articleAlias', $activeRecord->articleAlias, $activeRecord->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } } elseif ($table == 'tl_content') { // get include breadcrumbs that reference this content element $includes = \IncludeInfoHelper::getIncludes(array("cteAlias = ? AND type = 'alias'"), array($activeRecord->id)); // set include breadcrumbs if (count($includes) > 0) { $objTemplate->includes = $includes; } } elseif ($table == 'tl_article') { // get include breadcrumbs that reference this article $includes = \IncludeInfoHelper::getIncludes(array("articleAlias = ? AND type = 'article'"), array($activeRecord->id)); // set include breadcrumbs if (count($includes) > 0) { $objTemplate->includes = $includes; } } elseif ($table == 'tl_module') { // get include breadcrumbs that reference this module $includes = \IncludeInfoHelper::getIncludes(array("module = ? AND type = 'module'"), array($activeRecord->id)); // set include breadcrumbs if (count($includes) > 0) { $objTemplate->includes = $includes; } } // check for includes and add CSS if ($objTemplate->includes) { $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; } // return template return $objTemplate->parse(); }