public static getArticle ( mixed $varId, boolean $blnMultiMode = false, boolean $blnIsInsertTag = false, string $strColumn = 'main' ) : string | boolean | ||
$varId | mixed | The article ID or a Model object |
$blnMultiMode | boolean | If true, only teasers will be shown |
$blnIsInsertTag | boolean | If true, there will be no page relation |
$strColumn | string | The name of the column |
return | string | boolean | The article HTML markup or false |
public static function getArticle($varId, $blnMultiMode = false, $blnIsInsertTag = false, $strColumn = 'main')
{
/** @var PageModel $objPage */
global $objPage;
if (is_object($varId)) {
$objRow = $varId;
} else {
if (!$varId) {
return '';
}
$objRow = \ArticleModel::findByIdOrAliasAndPid($varId, !$blnIsInsertTag ? $objPage->id : null);
if ($objRow === null) {
return false;
}
}
// Check the visibility (see #6311)
if (!static::isVisibleElement($objRow)) {
return '';
}
// Print the article as PDF
if (isset($_GET['pdf']) && \Input::get('pdf') == $objRow->id) {
// Deprecated since Contao 4.0, to be removed in Contao 5.0
if ($objRow->printable == 1) {
@trigger_error('Setting tl_article.printable to "1" has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
$objArticle = new \ModuleArticle($objRow);
$objArticle->generatePdf();
} elseif ($objRow->printable != '') {
$options = \StringUtil::deserialize($objRow->printable);
if (is_array($options) && in_array('pdf', $options)) {
$objArticle = new \ModuleArticle($objRow);
$objArticle->generatePdf();
}
}
}
$objRow->headline = $objRow->title;
$objRow->multiMode = $blnMultiMode;
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getArticle']) && is_array($GLOBALS['TL_HOOKS']['getArticle'])) {
foreach ($GLOBALS['TL_HOOKS']['getArticle'] as $callback) {
static::importStatic($callback[0])->{$callback[1]}($objRow);
}
}
$objArticle = new \ModuleArticle($objRow, $strColumn);
$strBuffer = $objArticle->generate($blnIsInsertTag);
// Disable indexing if protected
if ($objArticle->protected && !preg_match('/^\\s*<!-- indexer::stop/', $strBuffer)) {
$strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n";
}
return $strBuffer;
}