tl_content::addCteType PHP Method

addCteType() public method

Add the type of content element
public addCteType ( array $arrRow ) : string
$arrRow array
return string
    public function addCteType($arrRow)
    {
        $key = $arrRow['invisible'] ? 'unpublished' : 'published';
        $type = $GLOBALS['TL_LANG']['CTE'][$arrRow['type']][0] ?: ' ';
        $class = 'limit_height';
        // Remove the class if it is a wrapper element
        if (in_array($arrRow['type'], $GLOBALS['TL_WRAPPERS']['start']) || in_array($arrRow['type'], $GLOBALS['TL_WRAPPERS']['separator']) || in_array($arrRow['type'], $GLOBALS['TL_WRAPPERS']['stop'])) {
            $class = '';
            if (($group = $this->getContentElementGroup($arrRow['type'])) !== null) {
                $type = $GLOBALS['TL_LANG']['CTE'][$group] . ' (' . $type . ')';
            }
        } elseif (in_array($arrRow['type'], $GLOBALS['TL_WRAPPERS']['single'])) {
            if (($group = $this->getContentElementGroup($arrRow['type'])) !== null) {
                $type = $GLOBALS['TL_LANG']['CTE'][$group] . ' (' . $type . ')';
            }
        }
        // Add the ID of the aliased element
        if ($arrRow['type'] == 'alias') {
            $type .= ' ID ' . $arrRow['cteAlias'];
        }
        // Add the protection status
        if ($arrRow['protected']) {
            $type .= ' (' . $GLOBALS['TL_LANG']['MSC']['protected'] . ')';
        } elseif ($arrRow['guests']) {
            $type .= ' (' . $GLOBALS['TL_LANG']['MSC']['guests'] . ')';
        }
        // Add the headline level (see #5858)
        if ($arrRow['type'] == 'headline') {
            if (is_array($headline = StringUtil::deserialize($arrRow['headline']))) {
                $type .= ' (' . $headline['unit'] . ')';
            }
        }
        // Limit the element's height
        if (!Config::get('doNotCollapse')) {
            $class .= ' h64';
        }
        $objModel = new ContentModel();
        $objModel->setRow($arrRow);
        return '
<div class="cte_type ' . $key . '">' . $type . '</div>
<div class="' . trim($class) . '">
' . StringUtil::insertTagToSrc($this->getContentElement($objModel)) . '
</div>' . "\n";
    }

Usage Example

 public function createChildRecord($arrRow)
 {
     $GLOBALS['content_classes']['count']++;
     $GLOBALS['content_classes']['current'] = $GLOBALS['content_classes']['classes'][$GLOBALS['content_classes']['count']];
     $tlContent = new \tl_content();
     return $tlContent->addCteType($arrRow);
 }
All Usage Examples Of tl_content::addCteType