numero2 / contao-tags

Adds the possibility to assign tags to individual elements.
GNU Lesser General Public License v3.0
1 stars 3 forks source link

Tags for events_full results in error #13

Closed denniserdmann closed 3 weeks ago

denniserdmann commented 1 month ago

Warning: foreach() argument must be of type array|object, string given for this line

<?php foreach( $this->tags as $tag ): ?>

According to the readme, it should be possible to use the same lines for event_full, too.

BTW: Event-List Modul ist working

bennyborn commented 1 month ago

Hmm. It seems like the getAllEvents-Hook isn't used for the EventReader module - at least in Contao 4.13 🤔

bennyborn commented 1 month ago

So Contao provides no Hooks for the ModuleEventReader at all. In order to display the tags in event_full you need to add the following code:

<?php

use Contao\ModuleEventReader;
use Contao\ModuleModel;
use Contao\System;

$moduleModel = ModuleModel::findOneById(19);
$module = new ModuleEventReader($moduleModel);

$tagListener = System::getContainer()->get('numero2_tags.listener.events');
$event = $tagListener->parseEvent($this->arrData, $module);

$this->tags = $event['tags'];
$this->tagsRaw = $event['tagsRaw'];

?>

Unfortunately we have no reference to the current reader module so you'll need to adjust the ID of the module in line 7 yourself.