Reputation: 23
I created a new extension to add some fields to the news extension.
In the backend everything works fine, I can add values to the fields and they are correctly saved in the database.
When I clear the cache and rebuild PHP Autoload Information it show in the frontend but after some hours the new fields disappears magically.
I have created the extension with the Extension Builder and added the field manually.
I read the ProxyClass generator info a lot of times but cannot see the fail.
Looks like I need connect the class in the cache or elsewhere.
I’m really desperate with this.
ext:albr_news_new_fields/Classes/Domain/Model/News.php
namespace Albr\AlbrNewsNewFields\Domain\Model;
class News extends \GeorgRinger\News\Domain\Model\News {
/**
* 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';
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
->registerImplementation(\GeorgRinger\News\Domain\Model\News::class,
\Albr\AlbrNewsNewFields\Domain\Model\News::class);
ext:albr_news_new_fields/ext_tables.php
call_user_func(
function()
{
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::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/Typoscript/setup.typoscript
plugin.tx_news {
persistence {
classes {
GeorgRinger\News\Domain\Model\News {
subclasses {
# three different classes are used for each news type
# 0 == default news
0 = Albr\AlbrNewsNewFields\Domain\Model\News
}
}
Albr\AlbrNewsNewFields\Domain\Model\NewsDefault {
mapping {
recordType = 0
tableName = tx_news_domain_model_news
}
}
Albr\AlbrNewsNewFields\Domain\Model\News {
mapping {
recordType = 0
tableName = tx_news_domain_model_news
}
}
}
}
}
config.tx_extbase {
persistence {
classes {
GeorgRinger\News\Domain\Model\News {
subclasses {
GeorgRinger\News\Domain\Model\News = Albr\AlbrNewsNewFields\Domain\Model\News
}
}
Albr\AlbrNewsNewFields\Domain\Model\News {
mapping {
tableName = tx_news_domain_model_news
}
}
}
}
}
I'm using: TYPO3 9.5.22 & News 7.3.1
Upvotes: 1
Views: 1319
Reputation: 746
If you want to keep record type = 0, then, I suggest you to do that :
plugin.tx_news {
persistence {
classes {
Albr\AlbrNewsNewFields\Domain\Model\News {
mapping {
recordType = 0
tableName = tx_news_domain_model_news
}
}
}
}
}
And in Configuration/TCA/Overrides/tx_news_domain_model_news.php, overrides type = 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,'
]
);
An set the tt_news dependencies in ext_emconf.php :
$EM_CONF[$_EXTKEY] = [
...
'constraints' => [
'depends' => [
'typo3' => '9.5.0-9.5.99',
'tt_news' => '7.3.1-7.3.99',
],
'conflicts' => [],
'suggests' => [],
],
];
Upvotes: 0
Reputation: 746
I guess that the problem is because you override the tx_news record type 0.
You'd better have something like this :
plugin.tx_news {
persistence {
classes {
GeorgRinger\News\Domain\Model\News {
subclasses {
3 = Albr\AlbrNewsNewFields\Domain\Model\News
}
}
Albr\AlbrNewsNewFields\Domain\Model\News {
mapping {
recordType = 3
tableName = tx_news_domain_model_news
}
}
}
}
}
and then, defined a new type of record in Configuration/TCA/Overrides/tx_news_domain_model_news.php containing your new field :
$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,'
];
Have a look in news/Configuration/TCA/tx_news_domain_model_news.php
Upvotes: 0
Reputation: 2921
ext_tables.php
should not be used for TCA manipulation any more, see https://docs.typo3.org/m/typo3/reference-coreapi/9.5/en-us/ExtensionArchitecture/ConfigurationFiles/Index.html#ext-tables-php
Also see the mention of Configuration/TCA/Overrides/tx_news_domain_model_news.php
in
https://docs.typo3.org/p/georgringer/news/master/en-us/DeveloperManual/ExtendNews/ProxyClassGenerator/Index.html
Upvotes: 0