104 lines
3.3 KiB
PHP
104 lines
3.3 KiB
PHP
<?php
|
|
|
|
use Evoweb\EwBloggy\Constants;
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
|
|
|
$languageFile = 'LLL:EXT:blog/Resources/Private/Language/locallang_db.xlf:';
|
|
|
|
// Add category types
|
|
$GLOBALS['TCA']['sys_category']['ctrl']['type'] = 'record_type';
|
|
$GLOBALS['TCA']['sys_category']['ctrl']['typeicon_column'] = 'record_type';
|
|
$GLOBALS['TCA']['sys_category']['ctrl']['typeicon_classes'][(string) Constants::CATEGORY_TYPE_BLOG] = 'record-blog-category';
|
|
|
|
ExtensionManagementUtility::addToAllTCAtypes(
|
|
'sys_category',
|
|
'record_type',
|
|
'',
|
|
'before:title'
|
|
);
|
|
|
|
$GLOBALS['TCA']['sys_category']['types'][(string) Constants::CATEGORY_TYPE_BLOG] =
|
|
$GLOBALS['TCA']['sys_category']['types'][1];
|
|
|
|
// Limit parent categories to blog types
|
|
$GLOBALS['TCA']['sys_category']['types'][Constants::CATEGORY_TYPE_BLOG]['columnsOverrides'] = [
|
|
'parent' => [
|
|
'config' => [
|
|
'foreign_table_where' => ' AND sys_category.record_type = ' . Constants::CATEGORY_TYPE_BLOG . ' ' .
|
|
' AND sys_category.pid = ###CURRENT_PID### ' .
|
|
($GLOBALS['TCA']['pages']['columns']['categories']['config']['foreign_table_where'] ?? '')
|
|
]
|
|
]
|
|
];
|
|
|
|
// Register fields
|
|
$GLOBALS['TCA']['sys_category']['columns'] = array_replace_recursive(
|
|
$GLOBALS['TCA']['sys_category']['columns'],
|
|
[
|
|
'record_type' => [
|
|
'label' => $languageFile . 'sys_category.record_type',
|
|
'config' => [
|
|
'type' => 'select',
|
|
'renderType' => 'selectSingle',
|
|
'items' => [
|
|
[
|
|
'label' => 'LLL:EXT:blog/Resources/Private/Language/locallang_tca.xlf:sys_category.record_type.blog',
|
|
'value' => (string) Constants::CATEGORY_TYPE_BLOG,
|
|
'icon' => 'record-blog-category'
|
|
]
|
|
],
|
|
'default' => (string) Constants::CATEGORY_TYPE_BLOG,
|
|
]
|
|
],
|
|
'slug' => [
|
|
'label' => $languageFile . 'sys_category.slug',
|
|
'config' => [
|
|
'type' => 'slug',
|
|
'generatorOptions' => [
|
|
'fields' => ['title'],
|
|
'replacements' => [
|
|
'/' => ''
|
|
],
|
|
],
|
|
'fallbackCharacter' => '-',
|
|
'eval' => 'uniqueInSite',
|
|
'default' => '',
|
|
'max' => '2048',
|
|
]
|
|
],
|
|
'posts' => [
|
|
'label' => $languageFile . 'sys_category.posts',
|
|
'config' => [
|
|
'type' => 'group',
|
|
'size' => 5,
|
|
'allowed' => 'pages',
|
|
'foreign_table' => 'pages',
|
|
'MM' => 'sys_category_record_mm',
|
|
'MM_match_fields' => [
|
|
'fieldname' => 'categories',
|
|
'tablenames' => 'pages',
|
|
],
|
|
'maxitems' => 1000
|
|
],
|
|
],
|
|
]
|
|
);
|
|
|
|
// Add slug field to all types
|
|
ExtensionManagementUtility::addToAllTCAtypes(
|
|
'sys_category',
|
|
'slug',
|
|
'',
|
|
'after:title'
|
|
);
|
|
|
|
// Add blog specific fields to blog categories
|
|
ExtensionManagementUtility::addToAllTCAtypes(
|
|
'sys_category',
|
|
'
|
|
--div--;' . $languageFile . 'sys_category.tabs.blog,
|
|
posts
|
|
',
|
|
(string) Constants::CATEGORY_TYPE_BLOG
|
|
);
|