I'm currently working on a project that uses the t3blog extension. In the backend, when creating a new post, you first enter a title and then you have to click on "create new" to add content to the post.
Ideally the client wants to remove the "create new" or at least have it create a new piece of content by default.
I'm digging through the TCA of the extension and I found where it adds that control, now I'm a bit stuck as I haven't hacked in TCA before, does anyone know how to modify the behavior of an "inline" type via TCA?
Here is the code that adds the control.
'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(
),
)
),
What I'm trying to do is to remove the "general" tab that is created and just have the "text" tab.
Any hints would be very much appreciated.
Just managed to fix this yesterday after a long session of head scratching, here is how:
Modified the TCA to this:
'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
)
)
Then I created a new empty extension. Inside the ext directory, created ext_tables.php with the following content:
<?php
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_inline.php'] = t3lib_extMgm::extPath($_EXTKEY).'ux_inline.php';
And inside 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:
}
}
Hope this will help someone else in the future.