lochmueller / calendarize

šŸ“† Best TYPO3 Calendar ever šŸ“†
http://typo3.org/extensions/repository/view/calendarize
74 stars 84 forks source link

Adding fields to events ā†’ how to access in frontend? #808

Closed bavarianbytes closed 3 months ago

bavarianbytes commented 3 months ago

Hi there, i tried to add a custom field to the event model through my own extension based on this core howto.

The field is visible in the backend flexform and saved to the database. But i don't get the property in the fluid template as part of the event (checked by <f:debug>{event}</f:debug> in Detail.html).

Am i doing something wrong or is the calendarize extension design different from others?

calendarize_extended/Classes/Domain/Model/Event.php:

<?php

namespace CD\CalendarizeExtended\Domain\Model;

class Event extends \HDNET\Calendarize\Domain\Model\Event {
    /**
     * @var string
     */
    protected $eventAttendanceMode = '';

    /**
     * @return string
     */
    public function getEventAttendanceMode(): string {
        return $this->eventAttendanceMode;
    }

    /**
     * @param string $jobid
     */
    public function setEventAttendanceMode(string $eventAttendanceMode): void {
        $this->eventAttendanceMode = $eventAttendanceMode;
    }
}

calendarize_extended/ext_localconf.php:

<?php

defined('TYPO3') or die();

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\HDNET\Calendarize\Domain\Model\Event::class] = [
    'className' => \CD\CalendarizeExtended\Domain\Model\Event::class,
];

calendarize_extended/Configuration/Extbase/Persistence/Classes.php:

<?php

return [
    \CD\CalendarizeExtended\Domain\Model\Event::class => [
        'tableName' => 'tx_calendarize_domain_model_event',
    ],
];
lochmueller commented 3 months ago

Hey @bavarianbytes

Please check the documentation of EXT:calendarize. The core concept do not work, because the IndexRepository is the default selection repository and the building process of the Event itself do not match to the core documentation.

BUT: The Event of EXT:calendarize is only a Default/Example. If you have other or more complex data structures, it is recommended to create your own model and "calendarize" it with the registration in ext_locaconf/ext_tables. This is the basic concept of the extension and should you if you do not need the default event.

I will close this issue.

Regards, Tim