如何解决Typo3 v10 - 扩展中的内容元素为空
我有一个 Typ3 扩展,它允许在扩展中创建内容元素 - 在 Typ3 v9 中它工作正常,但在 Typ3 v10 上它没有,当我在模板中调试时,我得到了这个结果:
contentElements => protected TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorageprototypeobject (empty)
内容元素已创建,并且在后端也可以在数据集中正确可见
我还尝试查看实现模拟行为的 tx_news 但我没有任何线索,对我来说似乎我做对了但是是的...,按照我使用的一些代码片段,您是否有想法:
在 setup.typoscript 中:
lib.contenttabs_fecontenttabs.contentElementRendering = RECORDS
lib.contenttabs_fecontenttabs.contentElementRendering {
tables = tt_content
source.current = 1
dontCheckPid = 1
}
在模型中(我尝试使用 sam 作为新闻):
/**
* Get content elements
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getContentElements()
{
return $this->contentElements;
}
/**
* Set content element list
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $contentElements content elements
*/
public function setContentElements($contentElements)
{
$this->contentElements = $contentElements;
}
/**
* Adds a content element to the record
*
* @param \Moc\Contenttabs\Domain\Model\TtContent $contentElement
*/
public function addContentElement(\Moc\Contenttabs\Domain\Model\TtContent $contentElement)
{
if ($this->getContentElements() === null) {
$this->contentElements = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
$this->contentElements->attach($contentElement);
}
/**
* Get id list of content elements
*
* @return string
*/
public function getContentElementIdList()
{
return $this->getIdOfContentElements();
}
/**
* Get translated id list of content elements
*
* @return string
*/
public function getTranslatedContentElementIdList()
{
return $this->getIdOfContentElements(false);
}
/**
* Collect id list
*
* @param bool $original
* @return string
*/
protected function getIdOfContentElements($original = true)
{
$idList = [];
$contentElements = $this->getContentElements();
if ($contentElements) {
foreach ($this->getContentElements() as $contentElement) {
if ($contentElement->getColPos() >= 0) {
$idList[] = $original ? $contentElement->getUid() : $contentElement->_getProperty('_localizedUid');
}
}
}
return implode(',',$idList);
}
在模板中:
<f:cObject typoscriptObjectPath="lib.contenttabs_fecontenttabs.contentElementRendering">
{tab.contentElementIdList}
</f:cObject>
一些 TCA 代码(似乎工作正常):
'content_elements' => [
'exclude' => 1,'l10n_mode' => 'mergeIfNotBlank','label' => 'Content Elements','config' => [
'type' => 'inline','allowed' => 'tt_content','foreign_table' => 'tt_content','foreign_sortby' => 'sorting','foreign_field' => 'tx_tabs_content_elements','minitems' => 0,'maxitems' => 99,'overrideChildTca' => [
'columns' => [
'colPos' => [
'config' => [
'default' => 99
]
],'CType' => [
'config' => [
'default' => 'textmedia'
]
]
]
],'appearance' => [
'collapseAll' => 1,'expandSingle' => 1,'levelLinksPosition' => 'bottom','useSortable' => 1,'showPossibleLocalizationRecords' => 1,'showRemovedLocalizationRecords' => 1,'showAllLocalizationLink' => 1,'showSynchronizationLink' => 1,'enabledControls' => [
'info' => false,]
]
]
],
提前致谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。