Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drop down menu 将TCA更改保存在选择框的TYPO3中_Drop Down Menu_Typo3_Onchange - Fatal编程技术网

Drop down menu 将TCA更改保存在选择框的TYPO3中

Drop down menu 将TCA更改保存在选择框的TYPO3中,drop-down-menu,typo3,onchange,Drop Down Menu,Typo3,Onchange,我在TCA中创建了一个新字段。我想列出所有文章并选择一篇,将文章设置为顶级文章 文章有一个UID,数据库有一个名为istoparticle的列。 tx_供应商_域_模型_文章是包含文章所有信息的表格 我增加了一个专栏 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', array( 'tx_test_istoparticle' => array( 'exclu

我在TCA中创建了一个新字段。我想列出所有文章并选择一篇,将文章设置为顶级文章

文章有一个UID,数据库有一个名为istoparticle的列。 tx_供应商_域_模型_文章是包含文章所有信息的表格

我增加了一个专栏

\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',

        )
    ),
));
使用userfunction

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,bodytext等等。但是我只能在数组中存储头!? 现在我在后端的选择框中列出了所有标题

如果我在后端选择了一篇文章,我必须做什么来保存我的主题文章


TCA是否有onChange方法?如果我选择了一个,我怎么能得到像Uid这样的信息呢

TCA配置中的项应至少有两个元素-第一个是标签,第二个是值。有更多的选择,但我认为你的情况不需要。您可以在此处阅读有关它们的信息:

这意味着您的usefFunc应该如下所示:

public function getTopArticles(&$param){
    $pid = $param['row']['pid'];
    $teasers = $this->getArticles($pid);

    foreach ($articles as $article) {

        $record = BackendUtility::getRecord('tx_vendor_domain_model_article', $article->getUid());
        $param['items'][] = [
            $record['header'],
            $record['uid'],
        ]
    }
}
是的,TCA中有
onChange
功能:

如果您使用的是早于8.6的TYPO3,则需要根据以下内容查找
requestUpdate