TYPO3 TCA - 如何在没有所有接口选项的情况下使用“内联”类型

时间:2009-04-05 09:48:29

标签: typo3 typo3-tca

我目前正在开发一个使用t3blog扩展的项目。在后端,在创建新帖子时,首先输入标题,然后必须单击“新建”以向帖子添加内容。

理想情况下,客户希望删除“新建”或至少默认创建新内容。

我正在挖掘扩展的TCA,我发现它添加了控件的位置,现在我有点卡住,因为我之前没有入侵过TCA,有没有人知道如何修改“内联“通过TCA类型?

以下是添加控件的代码。

'content' => Array (
        'exclude' => 1,
        'label' => 'LLL:EXT:t3blog/locallang_db.xml:tx_t3blog_post.content',
        'config' => array (
            'type' => 'inline',
            'foreign_table' => 'tt_content',
            'foreign_field' => 'irre_parentid',
            'foreign_table_field' => 'irre_parenttable',
            'maxitems' => 100,
            'appearance' => array(
                'showSynchronizationLink' => 0,
                'showAllLocalizationLink' => 0,
                'showPossibleLocalizationRecords' => 0,
                'showRemovedLocalizationRecords' => 0,
                'expandSingle' => 1
            ),
            'behaviour' => array(
            ),
        )

    ),

我要做的是删除已创建的“常规”标签,只有“文本”标签。

任何提示都会非常感激。

2 个答案:

答案 0 :(得分:1)

我的理解是“内联”类型指的是“IRRE”或“内联关系记录编辑”,这是TCA中相对较新且功能强大(通过TYPO3标准)的数据结构。您可能会发现this section of the TYPO3 Core API个文档可用作参考。

实际上,click执行Ajax调用以在后台创建新的数据库记录。但是,从我所看到的(使用这个和其他插件,如Powermail),我怀疑有一种方法可以跳过额外的点击而不做一些严重的黑客攻击/扩展T3核心本身。对不起,我不能得到更多的帮助,最近我刚刚遇到过这个问题。希望SO上有其他TYPO3黑客试过这个......

答案 1 :(得分:1)

在经历了长时间的头痛之后,昨天设法解决了这个问题,方法如下:

将TCA修改为:

    'content' => Array (
        'exclude' => 1,
        'label' => 'LLL:EXT:t3blog/locallang_db.xml:tx_t3blog_post.content',
        'config' => array (
            'type' => 'inline',
            'foreign_table' => 'tt_content',
            'foreign_field' => 'irre_parentid',
            'foreign_table_field' => 'irre_parenttable',
            'maxitems' => 100,
            'appearance' => array(
                'showSynchronizationLink' => 0,
                'showAllLocalizationLink' => 0,
                'showPossibleLocalizationRecords' => 0,
                'showRemovedLocalizationRecords' => 0,
                'expandSingle' => 1,
                'collapseAll' => 0
            ),
            'behaviour' => array(
            ),
            't3blog' => true
        )

    )

然后我创建了一个新的空扩展。在ext目录中,创建了具有以下内容的ext_tables.php:

<?php
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_inline.php'] = t3lib_extMgm::extPath($_EXTKEY).'ux_inline.php';

在ux_inline.php里面:

<?php
class ux_t3lib_TCEforms_inline extends t3lib_TCEforms_inline
{
    public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = false)
    {
        if(isset($config['t3blog']) && $config['t3blog'])
        {
            $GLOBALS['TCA']['tt_content']['types']['text']['showitem'] = 'bodytext;;9;richtext:rte_transform[flag=rte_enabled|mode=ts_css];3-3-3';
            $GLOBALS['TCA']['tt_content']['columns']['CType']['exclude'] = 1;
            $GLOBALS['TCA']['tt_content']['columns']['header']['exclude'] = 1;

            return;
        }
        else
        {
            return parent::renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
        }
    }

    public function getExpandedCollapsedState($table, $uid)
    {
        if(isset($_REQUEST['edit']['tx_t3blog_post']))
            return true;
        else
            return parent::getExpandedCollapsedState($table, $uid);
    }

    public function getLevelInteractionLink($type, $objectPrefix, $conf=array())
    {
            if(!isset($conf['t3blog']) || !$conf['t3blog'])
            {
                return parent::getLevelInteractionLink($type, $objectPrefix, $conf);
            }
            else
    {
        if((int) $conf['inline']['first'] > 0)
            return;
    }

    $nameObject = $this->inlineNames['object'];
    $attributes = array();
    switch($type) {
        case 'newRecord':
            $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.createnew', 1);
            $iconFile = 'gfx/new_el.gif';
            // $iconAddon = 'width="11" height="12"';
            $className = 'typo3-newRecordLink';
            $attributes['class'] = 'inlineNewButton '.$this->inlineData['config'][$nameObject]['md5'];
            $attributes['onclick'] = "return inline.createNewRecord('$objectPrefix')";
            $attributes['style'] = "display: none;";
            if (isset($conf['inline']['inlineNewButtonStyle']) && $conf['inline']['inlineNewButtonStyle']) {
                $attributes['style'] = $conf['inline']['inlineNewButtonStyle'];
            }
            if (isset($conf['appearance']['newRecordLinkAddTitle']) && $conf['appearance']['newRecordLinkAddTitle']) {
                $titleAddon = ' '.$GLOBALS['LANG']->sL($GLOBALS['TCA'][$conf['foreign_table']]['ctrl']['title'], 1);
            }
            $icon = ($iconFile ? '<img'.t3lib_iconWorks::skinImg($this->backPath, $iconFile, $iconAddon).' alt="'.htmlspecialchars($title.$titleAddon).'" />' : '');
            $link = $this->wrapWithAnchor($icon.$title.$titleAddon, '#', $attributes);
            return '<div'.($className ? ' class="'.$className.'"' : '').'>'.$link.'</div>';
            break;
        case 'localize':
            $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localizeAllRecords', 1);
            $iconFile = 'gfx/localize_el.gif';
            $className = 'typo3-localizationLink';
            $attributes['onclick'] = "return inline.synchronizeLocalizeRecords('$objectPrefix', 'localize')";
            break;
        case 'synchronize':
            $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:synchronizeWithOriginalLanguage', 1);
            $iconFile = 'gfx/synchronize_el.gif';
            $className = 'typo3-synchronizationLink';
            $attributes['class'] = 'inlineNewButton '.$this->inlineData['config'][$nameObject]['md5'];
            $attributes['onclick'] = "return inline.synchronizeLocalizeRecords('$objectPrefix', 'synchronize')";
            break;
    }
        // Create the link:

    }
}

希望这将有助于其他人。