Reputation: 3523
One way to render a tt_content element from own extension is this:
function getCE($id)
{
$conf['tables'] = 'tt_content';
$conf['source'] = $id;
$conf['dontCheckPid'] = 1;
return $this->cObj->cObjGetSingle('RECORDS', $conf);
}
Is it possible to add something to $conf so tt_content is rendered localized? Lets say I want the tt_content row with sys_language_uid = 2.
Alternative is to use the "getRecordOverlay", but then some functionality from cObjGetSingle will be lost.
UPDATE (it is for TYPO3 4.5.10)
Thank you for feedback. I somehow do it wrong with the 'CONTENT' way of doing it. I get nothing back from the function. Neither with or without the languageField.
Is it possible to post a working example? Lets say I know the tt_content uid is 3389 and it has been translated to language with uid 2. Or a link to a simple working example.
$conf = array(
'table' => 'tt_content',
'select.' => array(
'where' => 'colPos=0 AND uid = 3389',
'orderBy' => 'sorting',
'languageField' => 2 << if I leave this line out of the conf array I still get no result
)
);
return $this->cObj->cObjGetSingle('CONTENT', $conf);
BR. Anders
Upvotes: 1
Views: 2332
Reputation: 2684
You should replace RECORDS
with CONTENT
and adjust the $conf
array accordingly.
http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Content/Index.html
CONTENT
makes use of select
http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Select/Index.html and that again can use languageField
for the proper selection of translated content.
But you will have to connect it to the original $id
, since content elements do "know" their original element by the l18n_parent
field. You can use where
or andWhere
for it.
Upvotes: 0
Reputation: 37944
You might try using CONTENT instead of RECORDS:
$conf = array(
'table' => 'tt_content',
'select.' => array(
'where' => 'colPos=0',
'orderBy' => 'sorting',
'languageField' => 'sys_language_uid' // <- Here!
)
);
$conf['select.']['languageField'] = 'sys_language_uid';
return $this->cObj->cObjGetSingle('CONTENT', $conf);
Upvotes: 1