Get tt_content uid

痴心易碎 提交于 2019-12-19 08:13:46

问题


I am developing an extension that allows admins to save stuff to the database.

And I want that each instance of the extension should have it's own Id in the database. Is there some way to get the tt_content uid (which I guess is the extension instance Id) in the extension php.


回答1:


You fetch all tt_content's data in array:

$this->cObj->data

ie:

$uidOfCE = $this->cObj->data['uid'];

If you're using Extbase of course you need to get the content object first, ie:

$this->contentObj = $this->configurationManager->getContentObject();
debug($this->contentObj->data, "current tt_content's data");



回答2:


Here is the way (Tested in TYPO3 9.5.4)

This will return whole HTML of content which you can render directly

$conf = [
    'tables' => 'tt_content',
    'source' => $uid, //uid of tt_content
    'dontCheckPid' => 1
];
$html = $GLOBALS['TSFE']->cObj->cObjGetSingle('RECORDS', $conf);



回答3:


$contentId is content id in typo3 backend

$content_rec = $GLOBALS["TYPO3_DB"]->exec_SELECTgetrows('header,bodytext','tt_content','uid='.$contentId);
$this->markerArray['###content###'] = $content_rec[0]['bodytext'];



回答4:


For the effects of update that answer and know an plugin uid, you could debug \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->configurationManager->getContentObject()->data['uid'], 'parameter');

If is not complete the debug does not show the uid because configurationManager and contentObject use lazy loading.

This works and tested from TYPO3 8.7



来源:https://stackoverflow.com/questions/10447983/get-tt-content-uid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!