【发布时间】:2018-07-05 12:53:07
【问题描述】:
我在我的 TCA 中创建了我的新字段。我想列出所有文章并选择一篇,将文章设置为顶级文章。
文章有一个 UID,数据库有一个称为 istoparticle 的列。 tx_vendor_domain_model_article 是包含文章所有信息的表。
我添加了一个 TCA 列。
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', array(
'tx_test_istoparticle' => array(
'exclude' => 1,
'onChange' => 'reload',
'label' => 'Top Article',
'l10n_mode' => 'exclude',
'config' => array(
'type' => 'select',
'itemsProcFunc' => \Vendor\MyArticles\Hooks\Backend\Preview\ArticleRenderer::class . '->getArticleTitle',
)
),
));
使用用户函数
public function getTopArticles($param){
$pid = $param['row']['pid'];
$articles = $this->getArticles($pid);
foreach ($articles as $article) {
$record = BackendUtility::getRecord('tx_vendor_domain_model_article', $article->getUid());
$title = $record['header'];
$param['items'][][] = $title;
}
}
顺便说一句:$record 包含我需要的所有信息,UID,正文等。但我只能将标题存储在数组中!? 现在,我在后端的选择框中列出了所有标题。
如果我在后端选择一篇文章,我该怎么做才能保存我的 toparticle?
TCA 有 onChange 方法吗?如果我选择一个,我怎样才能得到像 Uid 这样的信息?
【问题讨论】:
标签: drop-down-menu typo3 onchange