我创建了一个新的扩展,为新闻扩展添加了一些字段
在后台,一切都很好,我可以向字段添加值,这些值会正确地保存在数据库中。
当我清除缓存并重建PHP自动加载信息时,它会显示在前端,但几个小时后,新字段会神奇地消失。
我已经用扩展生成器创建了扩展,并手动添加了字段
我读了很多次ProxyClass生成器信息,但看不到失败。
看起来我需要连接缓存或其他地方的类
我真的很绝望。
ext:albr_news_new_fields/Classes/Domain/Model/news.php
namespace AlbrAlbrNewsNewFieldsDomainModel;
class News extends GeorgRingerNewsDomainModelNews {
/**
* titulo1
*
* @var string
*/
protected $titulo1 = '';
ext:albr_news_new_fields/ext_localconf.php
defined('TYPO3_MODE') or die();
$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes']['Domain/Model/News'][] = 'albr_news_new_fields';
TYPO3CMSCoreUtilityGeneralUtility::makeInstance(TYPO3CMSExtbaseObjectContainerContainer::class)
->registerImplementation(GeorgRingerNewsDomainModelNews::class,
AlbrAlbrNewsNewFieldsDomainModelNews::class);
ext:albr_news_new_fields/ext_tables.php
call_user_func(
function()
{
TYPO3CMSCoreUtilityExtensionManagementUtility::addStaticFile('albr_news_new_fields', 'Configuration/TypoScript', 'Nuevos campos tx_news');
}
);
$tempColumns = Array (
'titulo1' => [
'exclude' => true,
'label' => 'LLL:EXT:albr_news_new_fields/Resources/Private/Language/locallang_db.xlf:titulo1',
'description' => 'LLL:EXT:albr_news_new_fields/Resources/Private/Language/locallang_db.xlf:titulo1.description',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'trim'
…
ext:albr_news_new_fields/Configuration/Typeoscript/setup.typeoscript
plugin.tx_news {
persistence {
classes {
GeorgRingerNewsDomainModelNews {
subclasses {
# three different classes are used for each news type
# 0 == default news
0 = AlbrAlbrNewsNewFieldsDomainModelNews
}
}
AlbrAlbrNewsNewFieldsDomainModelNewsDefault {
mapping {
recordType = 0
tableName = tx_news_domain_model_news
}
}
AlbrAlbrNewsNewFieldsDomainModelNews {
mapping {
recordType = 0
tableName = tx_news_domain_model_news
}
}
}
}
}
config.tx_extbase {
persistence {
classes {
GeorgRingerNewsDomainModelNews {
subclasses {
GeorgRingerNewsDomainModelNews = AlbrAlbrNewsNewFieldsDomainModelNews
}
}
AlbrAlbrNewsNewFieldsDomainModelNews {
mapping {
tableName = tx_news_domain_model_news
}
}
}
}
}
我使用的是:TYPO3 9.5.22&新闻7.3.1
ext_tables.php
不应再用于TCA操作,请参阅https://docs.typo3.org/m/typo3/reference-coreapi/9.5/en-us/ExtensionArchitecture/ConfigurationFiles/Index.html#ext-表php
另请参阅中提到的Configuration/TCA/Overrides/tx_news_domain_model_news.php
https://docs.typo3.org/p/georgringer/news/master/en-us/DeveloperManual/ExtendNews/ProxyClassGenerator/Index.html
我想问题是因为您覆盖了tx_news记录类型0。
你最好有这样的东西:
plugin.tx_news {
persistence {
classes {
GeorgRingerNewsDomainModelNews {
subclasses {
3 = AlbrAlbrNewsNewFieldsDomainModelNews
}
}
AlbrAlbrNewsNewFieldsDomainModelNews {
mapping {
recordType = 3
tableName = tx_news_domain_model_news
}
}
}
}
}
然后,在Configuration/TCA/Overrides/tx_news_domain_model_news.php中定义了一种新类型的记录,其中包含您的新字段:
$GLOBALS['TCA']['tx_news_domain_model_news']['types']['3'] = [
'showitem' => '
--palette--;;paletteCore,title,titulo1,--palette--;;paletteSlug,teaser,
--palette--;;paletteDate,
bodytext,
--div--;' . $ll . 'tx_news_domain_model_news.content_elements,
content_elements,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.media,
fal_media,fal_related_files,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;' . $ll . 'tx_news_domain_model_news.tabs.relations,
related,related_from,
related_links,tags,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.editorial;paletteAuthor,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.metatags;metatags,
--palette--;' . $ll . 'tx_news_domain_model_news.palettes.alternativeTitles;alternativeTitles,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;paletteLanguage,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;paletteHidden,
--palette--;;paletteAccess,
--div--;' . $ll . 'notes,
notes,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,'
];
查看news/Configuration/TCA/tx_news_domain_model_news.php
如果你想保持记录类型=0,那么,我建议你这样做:
plugin.tx_news {
persistence {
classes {
AlbrAlbrNewsNewFieldsDomainModelNews {
mapping {
recordType = 0
tableName = tx_news_domain_model_news
}
}
}
}
}
在配置/TCA/Overrides/tx_news_domain_model_news.php中,覆盖类型=0:
$GLOBALS['TCA']['tx_news_domain_model_news']['types']['0'] = array_replace_recursive(
$GLOBALS['TCA']['tt_content']['types']['0'],
[
'showitem' => '
--palette--;;paletteCore,title,titulo1,--palette--;;paletteSlug,teaser,
--palette--;;paletteDate,
bodytext,
--div--;' . $ll . 'tx_news_domain_model_news.content_elements,
content_elements,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.media,
fal_media,fal_related_files,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;' . $ll . 'tx_news_domain_model_news.tabs.relations,
related,related_from,
related_links,tags,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.editorial;paletteAuthor,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.metatags;metatags,
--palette--;' . $ll . 'tx_news_domain_model_news.palettes.alternativeTitles;alternativeTitles,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;paletteLanguage,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;paletteHidden,
--palette--;;paletteAccess,
--div--;' . $ll . 'notes,
notes,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.extended,'
]
);
在ext_emconf.php中设置tt_news依赖项:
$EM_CONF[$_EXTKEY] = [
...
'constraints' => [
'depends' => [
'typo3' => '9.5.0-9.5.99',
'tt_news' => '7.3.1-7.3.99',
],
'conflicts' => [],
'suggests' => [],
],
];