Sorry für das Selbstgespräch hier :-)
Anbei noch eine Lösung mittels mehrfacher Auswahl. Vielleicht kann das ja jemand brauchen.
contao/dca/tl_faq.php
Code:
<?php
#Custom Felder anlegen
use Contao\CoreBundle\DataContainer\PaletteManipulator;
$GLOBALS['TL_DCA']['tl_faq']['fields']['sichtbarkeit'] = [
'label' => ['Sichtbarkeit', 'Einstellung welche Kurstypen diese FAQ angezeigt bekommen.'],
'exclude' => true,
'search' => false,
'inputType' => 'checkbox',
'default' => 'Alle',
'options' => array('Alle', 'Blockkurse', 'Gruppenkurse', 'Onlinekurse'),
'eval' => array('multiple' => true, 'mandatory'=>true),
'sql' => [
'type' => 'blob',
],
];
PaletteManipulator::create()
->addLegend('Sichtbarkeit', 'title_legend', PaletteManipulator::POSITION_AFTER)
->addField('sichtbarkeit', 'Sichtbarkeit', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_faq')
;
mod_faqlist.html5
Code:
<?php $this->extend('block_unsearchable'); ?>
<?php $this->block('content'); ?>
<?php foreach ($this->faq as $category): ?>
<div class="mt-2 mb-5 faq">
<?php
$anker = str_replace(' ', '', trim($category['headline']));
?>
<a id="<?= strtolower($anker) ?>" class="anker"></a>
<h3><?= $category['headline'] ?></h3>
<ul class="<?= $category['class'] ?> question">
<?php foreach ($category['items'] as $faq): ?>
<?php $sichtbarkeit = unserialize($faq['sichtbarkeit']) ?>
<?php if(in_array("Alle",$sichtbarkeit,TRUE)): ?>
<li class="<?= $faq['class'] ?>"><a href="<?= $faq['href'] ?>" title="<?= $faq['title'] ?>"><?= $faq['question'] ?></a></li>
<!-- Frontend Mitgliedergruppe "Gruppenkurse" prüfen -->
<?php elseif(in_array("Gruppenkurse",$sichtbarkeit,TRUE) && FrontendUser::getInstance()->isMemberOf(20)): ?>
<li class="<?= $faq['class'] ?>"><a href="<?= $faq['href'] ?>" title="<?= $faq['title'] ?>"><?= $faq['question'] ?></a></li>
<!-- Frontend Mitgliedergruppe "Onlinekurse" prüfen -->
<?php elseif(in_array("Onlinekurse",$sichtbarkeit,TRUE) && FrontendUser::getInstance()->isMemberOf(133)): ?>
<li class="<?= $faq['class'] ?>"><a href="<?= $faq['href'] ?>" title="<?= $faq['title'] ?>"><?= $faq['question'] ?></a></li>
<!-- Frontend Mitgliedergruppe "Blockkurse" prüfen -->
<?php elseif(in_array("Blockkurse",$sichtbarkeit,TRUE) && FrontendUser::getInstance()->isMemberOf(134)): ?>
<li class="<?= $faq['class'] ?>"><a href="<?= $faq['href'] ?>" title="<?= $faq['title'] ?>"><?= $faq['question'] ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
<?php $this->endblock(); ?>
Lesezeichen