Contao\Hybrid::generate PHP Method

generate() public method

Parse the template
public generate ( ) : string
return string
    public function generate()
    {
        if ($this->objParent instanceof ContentModel && TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->objParent->invisible || $this->objParent->start != '' && $this->objParent->start > time() || $this->objParent->stop != '' && $this->objParent->stop < time())) {
            return '';
        }
        $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 = !empty($this->cssID[0]) ? ' id="' . $this->cssID[0] . '"' : '';
        $this->Template->class = trim($this->typePrefix . $this->strKey . ' ' . $this->cssID[1]);
        $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->objParent->classes) && is_array($this->objParent->classes)) {
            $this->Template->class .= ' ' . implode(' ', $this->objParent->classes);
        }
        return $this->Template->parse();
    }

Usage Example

Example #1
0
 /**
  * Remove name attributes in the back end so the form is not validated
  *
  * @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']['CTE']['form'][0]) . ' ###';
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->title;
         $objTemplate->href = 'contao/main.php?do=form&amp;table=tl_form_field&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     return parent::generate();
 }