Content::get()
\nn\t3::Content()->get($ttContentUid = NULL, $getRelations = false, $localize = true, $field = 'uid');
Loads the data of a tt_content element as a simple array:
\nn\t3::Content()->get( 1201 );
Copied!
Loading relations(media, assets, ...)
\nn\t3::Content()->get( 1201, true );
Copied!
Translations / Localization:
Do NOT automatically translate element if a different language has been set
\nn\t3::Content()->get( 1201, false, false );
Copied!
Get element in a DIFFERENT language than set in the frontend. Takes into account the fallback chain of the language that was set in the site config
\nn\t3::Content()->get( 1201, false, 2 );
Copied!
Get element with its own fallback chain. Completely ignores the chain, that was defined in the site config.
\nn\t3::Content()->get( 1201, false, [2,3,0] );
Copied!
Use your own field for recognition
\nn\t3::Content()->get( 'footer', true, true, 'content_uuid' );
Copied!
@param int|string $ttContentUid Content-Uid in the table tt_content (or string with a key)
@param bool $getRelations Also get relations / FAL?
@param bool $localize Translate the entry?
@param string $localize Translate the entry?
@param string $field If field other than uid is to be used
@return array
Source Code
public function get($ttContentUid = null, $getRelations = false, $localize = true, $field = 'uid')
{
if (!$ttContentUid) return [];
// Datensatz in der Standard-Sprache holen
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
$data = $queryBuilder
->select('*')
->from('tt_content')
->andWhere($queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($ttContentUid)))
->executeQuery()
->fetchAssociative();
if (!$data) return [];
$data = $this->localize('tt_content', $data, $localize);
if ($getRelations) {
$data = $this->addRelations($data);
}
return $data;
}
Copied!