I've been trying to extend the Location and Organizer models from tx_eventnews, but without any luck. The custom fields are not showing up in the frontend.
Everything in the backend works and is getting saved to the DB without any problems. It's mainly the frontend. I could solve this by using the signalslot "detailaction" from the NewsController and getting the saved values from my own repository, but this seems unnecessary if overriding/extending should work according to the Documentation "Add custom fields"
If I debug the Location (newsItem.location) and/or Organizer (newsItem.organizer) in the frontend, the default fields are rendered, but not the custom added fields. What am I missing?
Note: I have cleared the cache in the install tool multiple times throughout debugging.
ext_localconf:
$GLOBALS['TYPO3_CONF_VARS']['EXT']['eventnews']['classes']['Domain/Model/News'][] = 'my_website_extension';
$GLOBALS['TYPO3_CONF_VARS']['EXT']['eventnews']['classes']['Domain/Model/Location'][] = 'my_website_extension';
$GLOBALS['TYPO3_CONF_VARS']['EXT']['eventnews']['classes']['Domain/Model/Organizer'][] = 'my_website_extension';
I tried extending eventnews' News model because it did not work without. Classes\Domain\Model\News
/**
* News
*/
class News extends \GeorgRinger\Eventnews\Domain\Model\News
{
/**
* organizer
*
* @var \ThisIs\MyWebsiteExtension\Domain\Model\Organizer
*/
protected $organizer = null;
/**
* location
*
* @var \ThisIs\MyWebsiteExtension\Domain\Model\Location
*/
protected $location = null;
/**
* Returns the organizer
*
* @return \ThisIs\MyWebsiteExtension\Domain\Model\Organizer $organizer
*/
public function getOrganizer(): ?\ThisIs\MyWebsiteExtension\Domain\Model\Organizer
{
return $this->organizer;
}
/**
* Sets the organizer
*
* @param \ThisIs\MyWebsiteExtension\Domain\Model\Organizer $organizer
* @return void
*/
public function setOrganizer($organizer)
{
$this->organizer = $organizer;
}
/**
* Returns the location
*
* @return \ThisIs\MyWebsiteExtension\Domain\Model\Location $location
*/
public function getLocation(): ?\ThisIs\MyWebsiteExtension\Domain\Model\Location
{
return $this->location;
}
/**
* Sets the location
*
* @param \ThisIs\MyWebsiteExtension\Domain\Model\Location $location
* @return void
*/
public function setLocation($location)
{
$this->location = $location;
}
}
Classes\Domain\Model\Location:
/**
* Location
*/
class Location extends \GeorgRinger\Eventnews\Domain\Model\Location
{
/**
* @var string
*/
protected $telephone;
/**
* @var string
*/
protected $isOnline;
/**
* @return string
*/
public function getTelephone(): string
{
return $this->telephone;
}
/**
* @param string $telephone
*/
public function setTelephone(string $telephone): void
{
$this->telephone = $telephone;
}
/**
* @return string
*/
public function getIsOnline(): string
{
return $this->isOnline;
}
/**
* @param string $isOnline
*/
public function setIsOnline(string $isOnline): void
{
$this->isOnline = $isOnline;
}
}
Configuration\Extbase\Persistence\Classes:
return [
\ThisIs\MyWebsiteExtension\Domain\Model\News::class => [
'tableName' => 'tx_eventnews_domain_model_news',
],
\ThisIs\MyWebsiteExtension\Domain\Model\Location::class => [
'tableName' => 'tx_eventnews_domain_model_location',
],
\ThisIs\MyWebsiteExtension\Domain\Model\Organizer::class => [
'tableName' => 'tx_eventnews_domain_model_organizer',
],
];
Not sure if I need the propertymapping beside the tablenames. I've tried both.
ext_tables:
#
# Extend table structure for table 'tx_eventnews_domain_model_location'
#
CREATE TABLE tx_eventnews_domain_model_location (
telephone varchar(255) DEFAULT '' NOT NULL,
is_online tinyint(4) DEFAULT '0' NOT NULL,
);
#
# Extend table structure for table 'tx_eventnews_domain_model_organizer'
#
CREATE TABLE tx_eventnews_domain_model_organizer (
email varchar(255) DEFAULT '' NOT NULL,
telephone varchar(255) DEFAULT '' NOT NULL,
website varchar(255) DEFAULT '' NOT NULL,
);
TCA isn't the problem, so I left that out.
UPDATE: When extending tx_news itself it works like a charm, but eventnews (which is extended from tx_news already) is not working.
Installing the extension EXT:extender (example) works like a charm. My problem was that I used a website extension that didn't include a composer.json, so no extension-key was set that way. Extender expects to find a composer.json file with an extension_key.