public static function getContentElement($intId, $strColumn = 'main')
{
if (is_object($intId)) {
$objRow = $intId;
} else {
if (!strlen($intId) || $intId < 1) {
return '';
}
$objRow = \ContentModel::findByPk($intId);
if ($objRow === null) {
return '';
}
}
// Check the visibility (see #6311)
if (!static::isVisibleElement($objRow)) {
return '';
}
$strClass = \ContentElement::findClass($objRow->type);
// Return if the class does not exist
if (!class_exists($strClass)) {
static::log('Content element class "' . $strClass . '" (content element "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR);
return '';
}
$objRow->typePrefix = 'ce_';
/** @var ContentElement $objElement */
$objElement = new $strClass($objRow, $strColumn);
$strBuffer = $objElement->generate();
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getContentElement']) && is_array($GLOBALS['TL_HOOKS']['getContentElement'])) {
foreach ($GLOBALS['TL_HOOKS']['getContentElement'] as $callback) {
$strBuffer = static::importStatic($callback[0])->{$callback[1]}($objRow, $strBuffer, $objElement);
}
}
// Disable indexing if protected
if ($objElement->protected && !preg_match('/^\\s*<!-- indexer::stop/', $strBuffer)) {
$strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n";
}
return $strBuffer;
}