Contao\Widget::parse PHP Method

parse() public method

Parse the template file and return it as string
public parse ( array $arrAttributes = null ) : string
$arrAttributes array An optional attributes array
return string The template markup
    public function parse($arrAttributes = null)
    {
        if ($this->strTemplate == '') {
            return '';
        }
        $this->addAttributes($arrAttributes);
        $this->mandatoryField = $GLOBALS['TL_LANG']['MSC']['mandatory'];
        if ($this->customTpl != '' && TL_MODE == 'FE') {
            $this->strTemplate = $this->customTpl;
        }
        $strBuffer = $this->inherit();
        // HOOK: add custom parse filters (see #5553)
        if (isset($GLOBALS['TL_HOOKS']['parseWidget']) && is_array($GLOBALS['TL_HOOKS']['parseWidget'])) {
            foreach ($GLOBALS['TL_HOOKS']['parseWidget'] as $callback) {
                $this->import($callback[0]);
                $strBuffer = $this->{$callback[0]}->{$callback[1]}($strBuffer, $this);
            }
        }
        return $strBuffer;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Parse the template file and return it as string
  *
  * @param array $arrAttributes An optional attributes array
  *
  * @return string The template markup
  */
 public function parse($arrAttributes = null)
 {
     // Return a wildcard in the back end
     if (TL_MODE == 'BE') {
         /** @var BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         if ($this->fsType == 'fsStart') {
             $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['tl_form_field']['fsStart'][0]) . ' ###' . ($this->label ? '<br>' . $this->label : '');
         } else {
             $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['tl_form_field']['fsStop'][0]) . ' ###';
         }
         return $objTemplate->parse();
     }
     return parent::parse($arrAttributes);
 }
All Usage Examples Of Contao\Widget::parse