Contao\Module::generate PHP Метод

generate() публичный Метод

Parse the template
public generate ( ) : string
Результат string
    public function generate()
    {
        $this->Template = new \FrontendTemplate($this->strTemplate);
        $this->Template->setData($this->arrData);
        $this->compile();
        // Do not change this order (see #6191)
        $this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : '';
        $this->Template->class = trim('mod_' . $this->type . ' ' . $this->cssID[1]);
        $this->Template->cssID = !empty($this->cssID[0]) ? ' id="' . $this->cssID[0] . '"' : '';
        $this->Template->inColumn = $this->strColumn;
        if ($this->Template->headline == '') {
            $this->Template->headline = $this->headline;
        }
        if ($this->Template->hl == '') {
            $this->Template->hl = $this->hl;
        }
        if (!empty($this->objModel->classes) && is_array($this->objModel->classes)) {
            $this->Template->class .= ' ' . implode(' ', $this->objModel->classes);
        }
        return $this->Template->parse();
    }

Usage Example

Пример #1
0
 /**
  * Do not display the module if there are no articles
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['articlenav'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     /** @var PageModel $objPage */
     global $objPage;
     $this->objArticles = \ArticleModel::findPublishedWithTeaserByPidAndColumn($objPage->id, $this->strColumn);
     // Return if there are no articles
     if ($this->objArticles === null) {
         return '';
     }
     // Redirect to the first article if no article is selected
     if (!\Input::get('articles')) {
         if (!$this->loadFirst) {
             return '';
         }
         /** @var ArticleModel $objArticle */
         $objArticle = $this->objArticles->current();
         $strAlias = $objArticle->alias ?: $objArticle->id;
         $this->redirect($this->generateFrontendUrl($objPage->row(), '/articles/' . $strAlias));
     }
     return parent::generate();
 }
All Usage Examples Of Contao\Module::generate