Contao\FrontendTemplate::getCustomSections PHP Method

getCustomSections() public method

Return all custom layout sections
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use FrontendTemplate::sections() instead.
public getCustomSections ( string $strKey = null ) : string
$strKey string An optional section name
return string The section markup
    public function getCustomSections($strKey = null)
    {
        @trigger_error('Using FrontendTemplate::getCustomSections() has been deprecated and will no longer work in Contao 5.0. Use FrontendTemplate::sections() instead.', E_USER_DEPRECATED);
        if ($strKey != '' && !isset($this->positions[$strKey])) {
            return '';
        }
        $tag = 'div';
        if ($strKey == 'main') {
            /** @var PageModel $objPage */
            global $objPage;
            // Use the section tag in HTML5
            if ($objPage->outputFormat == 'html5') {
                $tag = 'section';
            }
        }
        $sections = '';
        // Standardize the IDs (thanks to Tsarma) (see #4251)
        foreach ($this->positions[$strKey] as $sect) {
            if (isset($this->sections[$sect['id']])) {
                $sections .= "\n" . '<' . $tag . ' id="' . \StringUtil::standardize($sect['id'], true) . '">' . "\n" . '<div class="inside">' . "\n" . $this->sections[$sect['id']] . "\n" . '</div>' . "\n" . '</' . $tag . '>' . "\n";
            }
        }
        if ($sections == '') {
            return '';
        }
        return '<div class="custom">' . "\n" . $sections . "\n" . '</div>' . "\n";
    }