TYPO3:如何在自己的扩展中呈现本地化的 tt_content [英] TYPO3: How to render localized tt_content in own extension

查看:23
本文介绍了TYPO3:如何在自己的扩展中呈现本地化的 tt_content的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从自己的扩展中呈现 tt_content 元素的一种方法是:

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);
}

是否可以向 $conf 添加内容以便 tt_content 呈现本地化?假设我想要 tt_content 行 sys_language_uid = 2.

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.

另一种方法是使用getRecordOverlay",但是 cObjGetSingle 的某些功能将丢失.

Alternative is to use the "getRecordOverlay", but then some functionality from cObjGetSingle will be lost.

更新(适用于TYPO3 4.5.10)

UPDATE (it is for TYPO3 4.5.10)

感谢您的反馈.我不知何故用内容"的方式做错了.我从该函数中一无所获.不管有没有languageField.

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.

是否可以发布一个工作示例?假设我知道 tt_content uid 是 3389 并且它已经被翻译成 uid 2 的语言.或者一个简单的工作示例的链接.

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.安德斯

推荐答案

您可以尝试使用 内容 而不是记录:

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);

这篇关于TYPO3:如何在自己的扩展中呈现本地化的 tt_content的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆