mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-11-21 19:16:08 +01:00
[TASK] added Fluid Template to list the Syllabus in an Accordion
This commit is contained in:
parent
f37a57e46e
commit
b73cd52526
2 changed files with 96 additions and 15 deletions
|
@ -84,21 +84,30 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
*/
|
*/
|
||||||
protected static function group(array $skills): array
|
protected static function group(array $skills): array
|
||||||
{
|
{
|
||||||
$domainTags = [];
|
$domainTagsWithId = [];
|
||||||
foreach ($skills as $skill) {
|
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;
|
||||||
|
}
|
||||||
|
$domainTagsWithId[] = $skill->toArray()['domainTag'];
|
||||||
}
|
}
|
||||||
$domainTags = array_unique($domainTags);
|
//remove items with duplicate title
|
||||||
|
$domainTagsWithId = array_map('unserialize', array_unique(array_map('serialize', $domainTagsWithId)));
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($domainTags as $domainTag) {
|
foreach ($domainTagsWithId as $domainTag) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'title' => $domainTag,
|
'title' => $domainTag['title'],
|
||||||
'skills' => array_filter($skills, function (Skill $skill) use ($domainTag) {
|
'uid' => $domainTag['uid'],
|
||||||
|
'skills' => array_filter($skills, function ($skill) use ($domainTag) {
|
||||||
if (!isset($skill->toArray()['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'];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,86 @@
|
||||||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
|
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
|
||||||
xmlns:sd="http://typo3.org/ns/SkillDisplay/SkilldisplayContent/ViewHelpers"
|
xmlns:sd="http://typo3.org/ns/SkillDisplay/SkilldisplayContent/ViewHelpers"
|
||||||
data-namespace-typo3-fluid="true">
|
data-namespace-typo3-fluid="true">
|
||||||
<f:for each="{skillSets}" as="skillSet">
|
<f:variable name="activeElement" value="{data.pi_flexform.default_element}"/>
|
||||||
<sd:skillGrouping skillSet="{skillSet}" as="domainGroup">
|
<f:variable name="currentVariants" value="{variants}"/>
|
||||||
<b>{domainGroup.title}</b><br/>
|
<div class="accordion" id="accordion-{data.uid}">
|
||||||
<f:for each="{domainGroup.skills}" as="skill">
|
<f:for each="{skillSets}" as="skillSet" iteration="iteration">
|
||||||
{skill.title}<br/>
|
<sd:skillGrouping skillSet="{skillSet}" as="domainGroup">
|
||||||
|
<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">
|
||||||
|
<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>
|
</f:for>
|
||||||
</sd:skillGrouping>
|
</div>
|
||||||
</f:for>
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue