0

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

<?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
                    }
                }
            }
        }
}

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

任何帮助,将不胜感激。

4

2 回答 2

0

您能否提供确切的错误日志以及您发布完整回溯的步骤,以便任何人都可以帮助您



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');

清除typo3temp,这将触发预期的结果我希望没有缓存机制,如果-则禁用它一段时间

于 2021-10-07T15:03:43.047 回答
0

在 TYPO3 v10 中,Extbase 持久性类的配置发生了变化:

变更日志

另请参阅新闻文档中的示例:(您当前正在遵循“自定义类型”方法)

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

于 2021-10-07T16:41:19.147 回答