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

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

Parse the template
public generate ( ) : string
Результат string
    public function generate()
    {
        if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start != '' && $this->start > time() || $this->stop != '' && $this->stop < time())) {
            return '';
        }
        $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('ce_' . $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

 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // Use the home directory of the current user as file source
     if ($this->useHomeDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if ($this->User->assignDir && $this->User->homeDir) {
             $this->folderSRC = $this->User->homeDir;
         }
     }
     // Return if there is no folder defined
     if (empty($this->folderSRC)) {
         return '';
     }
     // Get the folders from the database
     $this->objFolder = \FilesModel::findByUuid($this->folderSRC);
     if ($this->objFolder === null) {
         if (!\Validator::isUuid($this->folderSRC[0])) {
             return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         }
         return '';
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #4632)
     if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
         if (strpos(dirname($file), $this->objFolder->path) !== FALSE) {
             \Controller::sendFileToBrowser($file);
         }
     }
     return parent::generate();
 }
All Usage Examples Of Contao\ContentElement::generate