我正在尝试扩展新闻扩展以包含自定义输入字段。我已经创建了一个域模型:
<?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
}
}
}
}
}
我花了几个小时试图弄清楚为什么自定义输入字段没有被呈现到前端,不幸的是没有任何成功。
任何帮助,将不胜感激。