[TASK] added Fluid Template to list the Syllabus in an Accordion

This commit is contained in:
julianzangl 2023-07-07 14:35:42 +02:00
parent f37a57e46e
commit b73cd52526
2 changed files with 96 additions and 15 deletions

View file

@ -84,21 +84,30 @@ class SkillGroupingViewHelper extends AbstractViewHelper
*/
protected static function group(array $skills): array
{
$domainTags = [];
$domainTagsWithId = [];
foreach ($skills as $skill) {
$domainTags[] = isset($skill->toArray()['domainTag']) ? $skill->toArray()['domainTag']['title'] : "none";
if (!isset($skill->toArray()['domainTag'])) {
$domainTagsWithId[] = [
'uid' => 0,
'title' => 'none'
];
continue;
}
$domainTags = array_unique($domainTags);
$domainTagsWithId[] = $skill->toArray()['domainTag'];
}
//remove items with duplicate title
$domainTagsWithId = array_map('unserialize', array_unique(array_map('serialize', $domainTagsWithId)));
$result = [];
foreach ($domainTags as $domainTag) {
foreach ($domainTagsWithId as $domainTag) {
$result[] = [
'title' => $domainTag,
'skills' => array_filter($skills, function (Skill $skill) use ($domainTag) {
'title' => $domainTag['title'],
'uid' => $domainTag['uid'],
'skills' => array_filter($skills, function ($skill) use ($domainTag) {
if (!isset($skill->toArray()['domainTag'])) {
return $domainTag === "none";
return $domainTag['title'] === 'none';
}
return $skill->toArray()['domainTag']['title'] === $domainTag;
return $skill->toArray()['domainTag']['title'] === $domainTag['title'];
})
];
}

View file

@ -1,14 +1,86 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:sd="http://typo3.org/ns/SkillDisplay/SkilldisplayContent/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:for each="{skillSets}" as="skillSet">
<f:variable name="activeElement" value="{data.pi_flexform.default_element}"/>
<f:variable name="currentVariants" value="{variants}"/>
<div class="accordion" id="accordion-{data.uid}">
<f:for each="{skillSets}" as="skillSet" iteration="iteration">
<sd:skillGrouping skillSet="{skillSet}" as="domainGroup">
<b>{domainGroup.title}</b><br/>
<div class="accordion-item">
<h {data.subitems_header_layout} class="accordion-header"
id="accordion-heading-{data.uid}-{domainGroup.uid}">
<button
class="accordion-button{f:if(condition: '{activeElement} == {domainGroup.uid}', else:' collapsed')}"
type="button"
data-bs-toggle="collapse"
data-bs-target="#accordion-{data.uid}-{domainGroup.uid}"
data-bs-parent="#accordion-{data.uid}"
aria-expanded="{f:if(condition: '{activeElement} == {domainGroup.uid}', then: 'true', else: 'false')}"
aria-controls="accordion-{data.uid}-{domainGroup.uid}"
>
{domainGroup.title}
</button>
</h{data.subitems_header_layout}>
<div
id="accordion-{data.uid}-{domainGroup.uid}"
class="accordion-collapse collapse{f:if(condition: '{activeElement} == {domainGroup.uid}', then: ' show')}"
aria-labelledby="accordion-heading-{data.uid}-{domainGroup.uid}"
data-bs-parent="#accordion-{data.uid}"
>
<div class="accordion-body">
<div class="accordion-content accordion-content-{domainGroup.uid}">
<f:if condition="{domainGroup.files}">
<div class="accordion-content-item accordion-content-media">
<f:variable name="imageConfig">
{settings.responsiveimages.contentelements.accordion.{domainGroup.uid}}
</f:variable>
<bk2k:data.imageVariants as="variants" variants="{currentVariants}"
multiplier="{imageConfig.multiplier}"
gutters="{imageConfig.gutters}"
corrections="{imageConfig.corrections}"/>
<f:render partial="Media/Gallery"
arguments="{files: record.files, data: record.data, settings: settings, variants: variants}"/>
</div>
</f:if>
<div class="accordion-content-item accordion-content-text">
<ul>
<f:for each="{domainGroup.skills}" as="skill">
{skill.title}<br/>
<li>
<b>{skill.title}</b> <br>
<f:if condition="{skill.description}">
{skill.description->f:format.html()}
</f:if>
<!-- ANDERE VARIANTE: {skill.goals->f:format.html()} -->
<div class="accordion" id="sub-accordion-{skill.id}">
<div class="accordion-item">
<h2 class="accordion-header" id="sub-heading-{skill.id}">
<button class="accordion-button" type="button"
data-bs-toggle="collapse"
data-bs-target="#sub-collapse-{skill.id}" aria-expanded="true"
aria-controls="collapse-{skill.id}">
Show goals
</button>
</h2>
<div id="sub-collapse-{skill.id}" class="accordion-collapse collapse show"
aria-labelledby="sub-heading-{skill.id}"
data-bs-parent="#sub-accordion-{skill.id}">
<div class="accordion-body">
{skill.goals->f:format.html()}
</div>
</div>
</div>
</div>
</li>
</f:for>
</ul>
</div>
</div>
</div>
</div>
</div>
</sd:skillGrouping>
</f:for>
</div>
<hr>