mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-11-24 03:56:08 +01:00
[TASK] added ViewHelper for grouping skills by their domainTag
This commit is contained in:
parent
ffde64c04b
commit
60931303c0
2 changed files with 44 additions and 24 deletions
|
@ -36,7 +36,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||||
* <f:for each="{domainGroup.skills}" as="skill">
|
* <f:for each="{domainGroup.skills}" as="skill">
|
||||||
* {skill.name}<br />
|
* {skill.name}<br />
|
||||||
* </f:for>
|
* </f:for>
|
||||||
* </sd>
|
* </sd:skillGrouping>
|
||||||
*/
|
*/
|
||||||
class SkillGroupingViewHelper extends AbstractViewHelper
|
class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,8 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
array $arguments,
|
array $arguments,
|
||||||
Closure $renderChildrenClosure,
|
Closure $renderChildrenClosure,
|
||||||
RenderingContextInterface $renderingContext
|
RenderingContextInterface $renderingContext
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
/** @var Skill[] $skills */
|
/** @var Skill[] $skills */
|
||||||
$skills = $arguments['skills'];
|
$skills = $arguments['skills'];
|
||||||
/** @var SkillSet $skillSet */
|
/** @var SkillSet $skillSet */
|
||||||
|
@ -84,16 +85,24 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
*/
|
*/
|
||||||
protected static function group(array $skills): array
|
protected static function group(array $skills): array
|
||||||
{
|
{
|
||||||
$result = [
|
$domainTags = [];
|
||||||
/*
|
foreach ($skills as $skill) {
|
||||||
* [
|
$domainTags[] = isset($skill->toArray()['domainTag']) ? $skill->toArray()['domainTag']['title'] : "none";
|
||||||
* 'title' => 'Domain 1',
|
}
|
||||||
* 'skills' => [...skills]
|
$domainTags = array_unique($domainTags);
|
||||||
* ]
|
|
||||||
*/
|
|
||||||
];
|
|
||||||
|
|
||||||
// todo group skills based on domainTag|title
|
$result = [];
|
||||||
|
foreach ($domainTags as $domainTag) {
|
||||||
|
$result[] = [
|
||||||
|
'title' => $domainTag,
|
||||||
|
'skills' => array_filter($skills, function (Skill $skill) use ($domainTag) {
|
||||||
|
if (!isset($skill->toArray()['domainTag'])) {
|
||||||
|
return $domainTag === "none";
|
||||||
|
}
|
||||||
|
return $skill->toArray()['domainTag']['title'] === $domainTag;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
<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:for each="{skillSets}" as="skillSet">
|
||||||
|
<sd:skillGrouping skillSet="{skillSet}" as="domainGroup">
|
||||||
|
<b>{domainGroup.title}</b><br/>
|
||||||
|
<f:for each="{domainGroup.skills}" as="skill">
|
||||||
|
{skill.title}<br/>
|
||||||
|
</f:for>
|
||||||
|
</sd:skillGrouping>
|
||||||
|
</f:for>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<f:for each="{skillSets}" as="skillSet">
|
||||||
{f:render(partial: 'VerificationBox', arguments: {
|
{f:render(partial: 'VerificationBox', arguments: {
|
||||||
title: skillSet.name,
|
title: skillSet.name,
|
||||||
count: '{skillSet.skills -> f:count()}',
|
count: '{skillSet.skills -> f:count()}',
|
||||||
|
@ -10,5 +21,5 @@
|
||||||
verificationUrl: '{sd:verification.url(skillSet: skillSet.id, campaign: data.skilldisplay_campaign)}',
|
verificationUrl: '{sd:verification.url(skillSet: skillSet.id, campaign: data.skilldisplay_campaign)}',
|
||||||
description: skillSet.description
|
description: skillSet.description
|
||||||
})}
|
})}
|
||||||
</f:for>
|
</f:for>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue