编程语言
首页 > 编程语言> > php – 无法为新闻条目生成TYPO3 tt_news类别树

php – 无法为新闻条目生成TYPO3 tt_news类别树

作者:互联网

我正在使用我的TYPO3 v7.6.18的tt_news扩展(刚刚从6.2.31升级)
我遇到了类别树的问题.我为tt_news类别渲染做了一些调试,这是到目前为止的问题:

旧的tca.php看起来像这样:

'category' => Array(
    'exclude' => 1,
    'label'   => 'LLL:EXT:tt_news/locallang_tca.xml:tt_news.category',
    'config'  => Array(
        'type'          => 'select',
        'form_type'     => 'user',
        'userFunc'      => 'tx_ttnews_TCAform_selectTree->renderCategoryFields',
        'treeView'      => 1,
        'foreign_table' => 'tt_news_cat',
        'autoSizeMax'   => 50,
        'minitems'      => $confArr['requireCategories'] ? 1 : 0,
        'maxitems'      => 500,
        'MM'            => 'tt_news_cat_mm',
    ),
),

这给了我错误的结果,这意味着,我没有树,而是多选.现在,当我将类型更改为用户时,我收到此错误:

Fatal error: Call to undefined method TYPO3\CMS\Backend\Form\Element\UserElement::addSelectOptionsToItemArray() in /home/portal/typo3project/typo3conf/ext/tt_news/lib/class.tx_ttnews_TCAform_selectTree.php on line 167

我检查了类tx_ttnews_TCAform_selectTree方法renderCategoryFieldsand中的行,它看起来像这样:

$selItems = $fobj->addSelectOptionsToItemArray($fobj->initItemArray($this->PA['fieldConf']),$this->PA['fieldConf'],$fobj->setTSconfig($table,$row),$field);

$fobj在函数定义中作为引用:函数renderCategoryFields(& $PA,& $fobj),似乎它在某处定义错误,因为addSelectOptionsToItemArray位于FormEngine而不是UserElement.

由于该方法在tca中被调用,如tx_ttnews_TCAform_selectTree-> renderCategoryFields,我无法更改类,它正在使用.

任何想法如何解决这一问题?

解决方法:

从TYPO3 7开始,您不需要定义自定义用户函数来将列表呈现为树.选择类型字段有一个renderType TCA configuration option,可以通过selectTree值定义树渲染.

所以配置应如下所示:

'category' => Array(
    'exclude' => 1,
    'label'   => 'LLL:EXT:tt_news/locallang_tca.xml:tt_news.category',
    'config'  => Array(
        'type'          => 'select',
        'renderType'    => 'selectTree',
        'foreign_table' => 'tt_news_cat',
        'autoSizeMax'   => 50,
        'minitems'      => $confArr['requireCategories'] ? 1 : 0,
        'maxitems'      => 500,
        'MM'            => 'tt_news_cat_mm',
        'treeConfig'    => array(
            'parentField' => 'parent_category',
        ),
    ),
),

此外,您可能希望使用treeConfig configuration option进行一些视觉调整.

标签:php,typo3,tt-news,typo3-extensions
来源: https://codeday.me/bug/20190627/1307227.html