ew_bloggy/Configuration/TCA/Overrides/pages-blog.php
2025-01-21 20:22:57 +01:00

207 lines
7.8 KiB
PHP

<?php
// Add new page types as possible select item:
use Evoweb\EwBloggy\Constants;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
ExtensionManagementUtility::addTcaSelectItem(
'pages',
'doktype',
[
'label' => 'LLL:EXT:ew_bloggy/Resources/Private/Language/locallang_tca.xlf:pages.doktype.blog-post',
'value' => (string) Constants::DOKTYPE_BLOG_POST,
'icon' => 'record-blog-post',
],
'1',
'after'
);
// Add icon for new page types:
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][(string) Constants::DOKTYPE_BLOG_POST] = 'record-blog-post';
$GLOBALS['TCA']['pages']['types'][(string) Constants::DOKTYPE_BLOG_POST]
= $GLOBALS['TCA']['pages']['types'][PageRepository::DOKTYPE_DEFAULT];
$languageFile = 'LLL:EXT:ew_bloggy/Resources/Private/Language/locallang_db.xlf:';
// Register fields
$GLOBALS['TCA']['pages']['columns'] = array_replace_recursive(
$GLOBALS['TCA']['pages']['columns'],
[
'crdate' => [
'label' => 'crdate',
'config' => [
'type' => 'passthrough',
],
],
'archive_date' => [
'label' => $languageFile . 'pages.archive_date',
'config' => [
'type' => 'datetime',
'size' => '13',
'default' => '0',
'behaviour' => [
'allowLanguageSynchronization' => true
]
],
],
'publish_date' => [
'label' => $languageFile . 'pages.publish_date',
'config' => [
'type' => 'datetime',
'size' => '13',
'default' => '0',
'behaviour' => [
'allowLanguageSynchronization' => true
]
],
],
'featured_image' => [
'label' => $languageFile . 'pages.featured_image',
'config' => [
'type' => 'file',
'minitems' => 0,
'maxitems' => 1,
'allowed' => 'common-image-types',
'behaviour' => [
'allowLanguageSynchronization' => true
]
],
],
'authors' => [
'label' => $languageFile . 'pages.authors',
'l10n_mode' => 'exclude',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'multiple' => false,
'foreign_table' => 'tx_ewbloggy_domain_model_author',
'foreign_table_where' => 'AND {#tx_ewbloggy_domain_model_author}.{#sys_language_uid} IN (0,-1)'
. ' AND {#tx_ewbloggy_domain_model_author}.{#pid} = ###PAGE_TSCONFIG_ID###'
. ' ORDER BY tx_ewbloggy_domain_model_author.name ASC',
'MM' => 'tx_ewbloggy_post_author_mm',
'minitems' => 0,
'maxitems' => 99999
],
],
]
);
ExtensionManagementUtility::addFieldsToPalette(
'pages',
'publish_date',
'publish_date, archive_date'
);
ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'
--div--;' . $languageFile . 'pages.tabs.blog,
--palette--;' . $languageFile . 'pages.palettes.publish_date;publish_date,
featured_image,
tags,
authors,
comments_active,
comments
',
(string) Constants::DOKTYPE_BLOG_POST,
'after:subtitle'
);
$GLOBALS['TCA']['pages']['types'][Constants::DOKTYPE_BLOG_POST]['columnsOverrides'] = [
'categories' => [
'config' => [
'behaviour' => [
'allowLanguageSynchronization' => true
],
'foreign_table_where' => 'AND sys_category.sys_language_uid IN (0,-1)'
. ' AND sys_category.pid = ###PAGE_TSCONFIG_ID###',
]
],
'featured_image' => [
'config' => [
'maxitems' => 10,
'overrideChildTca' => [
'columns' => [
'description' => [
'type' => 'input',
],
'crop' => [
'config' => [
'cropVariants' => [
'default' => [
'disabled' => true,
],
'latest' => [
'title' => 'Blog Latest',
'allowedAspectRatios' => [
'910:1080' => [
'title' => '910:1080',
'value' => 910 / 1080,
],
],
'selectedRatio' => '910:1080',
'cropArea' => [
'x' => 0.0,
'y' => 0.0,
'width' => 1.0,
'height' => 1.0,
],
],
'list' => [
'title' => 'Blog Archive',
'allowedAspectRatios' => [
'1:1' => [
'title' => '1:1',
'value' => 1,
],
],
'selectedRatio' => '1:1',
'cropArea' => [
'x' => 0.0,
'y' => 0.0,
'width' => 1.0,
'height' => 1.0,
],
],
'details' => [
'title' => 'Blog Detail',
'allowedAspectRatios' => [
'1068:600' => [
'title' => '1068:600',
'value' => 1068 / 600,
],
],
'selectedRatio' => '1068:600',
'cropArea' => [
'x' => 0.0,
'y' => 0.0,
'width' => 1.0,
'height' => 1.0,
],
],
'opengraph' => [
'title' => 'Opengraph',
'allowedAspectRatios' => [
'1200:627' => [
'title' => '1200:627',
'value' => 1200 / 627,
],
],
'selectedRatio' => '1200:627',
'cropArea' => [
'x' => 0.0,
'y' => 0.0,
'width' => 1.0,
'height' => 1.0,
],
],
],
],
],
],
],
],
]
];