I extended the tt_content table with an relationship to the tags of the news extension. (So I can Tag all tt_content elements.)
The methods like findAll and findByUid always return an empty QueryResultInterface.
I created the extension with extensionbuilder. I defined the Storage in the extensions right and ignore the storage on own methods.
ext_typoscript_setup.txt:
config.tx_extbase {
persistence {
classes {
EXAMP\ExampContentTagging\Domain\Model\ContentTagRelation {
mapping {
tableName = tt_content
recordType = Tx_ExampContentTagging_ContentTagRelation
}
}
}
}
}
ContentTagRelationRepository.php:
<?php
namespace EXAMP\ExampContentTagging\Domain\Repository;
/**
* The repository for ContentTagRelations
*/
class ContentTagRelationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* @var array
*/
protected $defaultOrderings = array(
'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
);
/**
* Find tt_content by a given pid
*
* @param array $includeIdList list of id s
* @param array $excludeIdList list of id s
* @return QueryInterface
*/
public function findByTagIdList(array $includeIdList, array $excludeIdList = [])
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
return $query->execute();
}
TCA/Overrides/tt_content.php:
defined('TYPO3_MODE') || die();
if (!isset($GLOBALS['TCA']['tt_content']['ctrl']['type'])) {
if (file_exists($GLOBALS['TCA']['tt_content']['ctrl']['dynamicConfigFile'])) {
require_once($GLOBALS['TCA']['tt_content']['ctrl']['dynamicConfigFile']);
}
// no type field defined, so we define it here. This will only happen the first time the extension is installed!!
$GLOBALS['TCA']['tt_content']['ctrl']['type'] = 'tx_extbase_type';
$tempColumnstx_exampcontenttagging_tt_content = [];
$tempColumnstx_exampcontenttagging_tt_content[$GLOBALS['TCA']['tt_content']['ctrl']['type']] = [
'exclude' => true,
'label' => 'LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tx_exampcontenttagging.tx_extbase_type',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['ContentTagRelation','Tx_exampContentTagging_ContentTagRelation']
],
'default' => 'Tx_exampContentTagging_ContentTagRelation',
'size' => 1,
'maxitems' => 1,
]
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $tempColumnstx_exampcontenttagging_tt_content);
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'tx_news_domain_model_tag'
);
$tmp_examp_content_tagging_columns = [
'tx_news_domain_model_tag' => [
'exclude' => true,
'label' => 'LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tx_exampcontenttagging_domain_model_contenttagrelation.tx_news_domain_model_tag',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_news_domain_model_tag',
'MM' => 'tx_exampcontenttagging_contenttagrelation_tag_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => [
'_PADDING' => 1,
'_VERTICAL' => 1,
'edit' => [
'module' => [
'name' => 'wizard_edit',
],
'type' => 'popup',
'title' => 'Edit', // todo define label: LLL:EXT:.../Resources/Private/Language/locallang_tca.xlf:wizard.edit
'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif',
'popup_onlyOpenIfSelected' => 1,
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
],
'add' => [
'module' => [
'name' => 'wizard_add',
],
'type' => 'script',
'title' => 'Create new', // todo define label: LLL:EXT:.../Resources/Private/Language/locallang_tca.xlf:wizard.add
'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif',
'params' => [
'table' => 'tx_news_domain_model_tag',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
],
],
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content',$tmp_examp_content_tagging_columns);
/* inherit and extend the show items from the parent class */
if (isset($GLOBALS['TCA']['tt_content']['types']['1']['showitem'])) {
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] = $GLOBALS['TCA']['tt_content']['types']['1']['showitem'];
} elseif(is_array($GLOBALS['TCA']['tt_content']['types'])) {
// use first entry in types array
$tt_content_type_definition = reset($GLOBALS['TCA']['tt_content']['types']);
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] = $tt_content_type_definition['showitem'];
} else {
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] = '';
}
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] .= ',--div--;LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tx_exampcontenttagging_domain_model_contenttagrelation,';
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] .= 'tx_news_domain_model_tag';
$GLOBALS['TCA']['tt_content']['columns'][$GLOBALS['TCA']['tt_content']['ctrl']['type']]['config']['items'][] = ['LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tt_content.tx_extbase_type.Tx_exampContentTagging_ContentTagRelation','Tx_exampContentTagging_ContentTagRelation'];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
'',
'EXT:/Resources/Private/Language/locallang_csh_.xlf'
);
Mostly to this problem, the solution is to check if the right storage is set. But I did this and still have the problem. So I think tt_content is the problem. But the only thing I could find to this was:
"tt_content is special."
Which dosen't help. (Offtopic: This Typo3 Documentation makes me mad every time I've to look into it.)