TYPO3 将自定义输入字段添加到新闻扩展

TYPO3 add custom input fields to News Extension

我正在尝试扩展新闻扩展以包含自定义输入字段。我已经创建了一个领域模型:

<?php
    
    namespace PegasusWerbeagenturGmbh\NewsExtend\Domain\Model;
    
    /**
     * News model for default news
     *
     * @package TYPO3
     * @subpackage tx_news
     */
    class NewsExtend extends \GeorgRinger\News\Domain\Model\NewsDefault
    {
        /**
         * @var string
         */
        protected $address;
    
        /**
         * @var string
         */
        protected $price;
        
        /**
         * @var int
         */
        protected $roomNr;
    
        /**
         * @var int
         */
        protected $bedNr;
    
        /**
         * @var int
         */
        protected $bathroomNr;
    
        /**
         * Get address
         *
         * @return string
         */
        public function getAdress()
        {
            return $this->address;
        }
    
        /**
         * Set address
         *
         * @param string $address address
         */
        public function setAdress($address)
        {
            $this->address = $address;
        }
    
    
        /**
         * Get price
         *
         * @return string
         */
        public function getPrice()
        {
            return $this->price;
        }
    
        /**
         * Set price
         *
         * @param string $price price
         */
        public function setPrice($price)
        {
            $this->price = $price;
        }
    
        /**
         * Get roomNr
         *
         * @return int
         */
        public function getRoomNr()
        {
            return $this->roomNr;
        }
    
        /**
         * Set roomNr
         *
         * @param int $roomNr roomNr
         */
        public function setRoomNr($roomNr)
        {
            $this->roomNr = $roomNr;
        }
    
        /**
         * Get bedNr
         *
         * @return int
         */
        public function getBedNr()
        {
            return $this->bedNr;
        }
    
        /**
         * Set bedNr
         *
         * @param int $bedNr bedNr
         */
        public function setBedNr($bedNr)
        {
            $this->bedNr = $bedNr;
        }
    
        /**
         * Get bathroomNr
         *
         * @return int
         */
        public function getBathroomNr()
        {
            return $this->bathroomNr;
        }
    
        /**
         * Set bathroomNr
         *
         * @param int $bathroomNr bathroomNr
         */
        public function setBathroomNr($bathroomNr)
        {
            $this->bathroomNr = $bathroomNr;
        }
    
    }

并扩展数据库结构如下:

CREATE TABLE tx_news_domain_model_news (
        address varchar(255) DEFAULT '' NOT NULL,
        price varchar(255) DEFAULT '' NOT NULL,
        roomNr int(8) DEFAULT 0 NOT NULL,
        bedNr int(8) DEFAULT 0 NOT NULL,
        bathroomNr int(8) DEFAULT 0 NOT NULL
);

在后端创建了自定义输入字段(效果很好)

    'address' => [
        'exclude' => false,
        'label' => 'Adresse',
        'config' => [
            'type' => 'input',
            'size' => 30,
        ]
    ],
    'price' => [
        'exclude' => false,
        'label' => 'Preis',
        'config' => [
            'type' => 'input',
            'size' => 30,
        ]
    ],
    'roomNr' => [
        'exclude' => false,
        'label' => 'Zimmer Anzahl',
        'config' => [
            'type' => 'input',
            'size' => 30,
        ]
    ],
    'bedNr' => [
        'exclude' => false,
        'label' => 'Betten Anzahl',
        'config' => [
            'type' => 'input',
            'size' => 30,
        ]
    ],
    'bathroomNr' => [
        'exclude' => false,
        'label' => 'Badezimmer Anzahl',
        'config' => [
            'type' => 'input',
            'size' => 30,
        ]
    ],


'types' => [
    // default news
    '0' => [
        'showitem' => '
                --palette--;;paletteCore,title,--palette--;;paletteSlug,teaser,
                --palette--;;paletteDate,
                bodytext,
                --palette--;;ApartmentDetails,

    'ApartmentDetails' => [
        'showitem' => '
            address, price, roomNr, bedNr, bathroomNr
        ',
    ],

最后编辑了我的 setup.typoscript

    plugin.tx_news {
        persistence {
            classes {
                GeorgRinger\News\Domain\Model\NewsDefault {
                    subclasses {
                        0 = PegasusWerbeagenturGmbh\NewsExtend\Domain\Model\NewsExtend
                    }
                }
                PegasusWerbeagenturGmbh\NewsExtend\Domain\Model\NewsExtend {
                    mapping {
                        tableName = tx_news_domain_model_news
                        recordType = 0
                    }
                }
            }
        }
}

我花了几个小时试图弄清楚为什么自定义输入字段没有呈现到前端,不幸的是没有任何成功。

如有任何帮助,我们将不胜感激。

能否请您提供准确的错误日志以及您执行的步骤post完整的追溯以便任何人都可以帮助您



To add your extension typoscript to the list of selectable typoscript templates add the following to your EXT:news_extend/ext_tables.php

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'News Extend');

clear typo3temp 这会触发预期的结果我希望没有缓存机制如果-然后禁用它一段时间

在 TYPO3 v10 中,Extbase 持久性的配置 类 已更改:

Changelog

另请参阅 news documentation 中的示例:(您目前正在遵循“自定义类型”方法)

注意:版本 select 或该文档中的版本似乎具有误导性 - select TYPO3v10 + v11 的“master”