从自己的扩展中呈现tt_content元素的一种方法是:
function getCE($id)
{
$conf['tables'] = 'tt_content';
$conf['source'] = $id;
$conf['dontCheckPid'] = 1;
return $this->cObj->cObjGetSingle('RECORDS', $conf);
}
是否有可能在$ conf中添加内容以使tt_content呈现本地化?假设我想要使用sys_language_uid = 2的tt_content行。
替代方法是使用“getRecordOverlay”,但cObjGetSingle的某些功能将丢失。
更新(适用于TYPO3 4.5.10)
感谢您的反馈。我以某种方式做错了“内容”的做法。我从功能中得不到任何回报。无论是否使用languageField。
是否可以发布一个有效的例子?让我们说我知道tt_content uid是3389并且它已经被uid 2翻译成了语言。或者链接到一个简单的工作示例。
$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。安德斯
答案 0 :(得分:1)
您可以尝试使用CONTENT代替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);
答案 1 :(得分:0)
您应该将RECORDS
替换为CONTENT
并相应地调整$conf
数组。
http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Content/Index.html
CONTENT
使用select
http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Select/Index.html并再次使用languageField
来正确选择翻译的内容。
但是您必须将其连接到原始$id
,因为内容元素通过l18n_parent
字段“知道”其原始元素。您可以使用where
或andWhere
。