diff --git a/Classes/ViewHelpers/ItemTypeIconNameViewHelper.php b/Classes/ViewHelpers/ItemTypeIconNameViewHelper.php new file mode 100644 index 0000000..81da14a --- /dev/null +++ b/Classes/ViewHelpers/ItemTypeIconNameViewHelper.php @@ -0,0 +1,42 @@ +registerArgument('iconPackKey', 'string', 'Name of the key for the IconPack (from Iconpack.yaml)', true); + $this->registerArgument('itemType', 'string', 'Name of the itemType (from Zotero)', true); + } + + public static function renderStatic( + array $arguments, + \Closure $renderChildrenClosure, + RenderingContextInterface $renderingContext) + : ?string + { + // get installed icon names from the t3x Iconpack Extension with Key 'lziconsr' as Array + $iconpackFactory = GeneralUtility::makeInstance(IconpackFactory::class); + $iconPackKey = $arguments['iconPackKey']; + $availableIconsArray = $iconpackFactory->queryConfig($iconPackKey, 'icons'); + + // Check if itemType exists as a key in the array + $itemType = $arguments['itemType']; + if (array_key_exists($itemType, $availableIconsArray)) { + return $iconPackKey.','.$itemType; + } + + // else Return default icon + return 'lziconsr,lisztDocument'; + + } +} diff --git a/Configuration/Iconpack/LisztSearchResultsIconpack.yaml b/Configuration/Iconpack/LisztSearchResultsIconpack.yaml index 70dbdfa..e7e06b3 100644 --- a/Configuration/Iconpack/LisztSearchResultsIconpack.yaml +++ b/Configuration/Iconpack/LisztSearchResultsIconpack.yaml @@ -43,7 +43,7 @@ iconpack: - birth - corporation - open-access - - location + - place - person - death - work diff --git a/Resources/Private/Templates/Search/Index.html b/Resources/Private/Templates/Search/Index.html index 89fc34d..bf5c69c 100644 --- a/Resources/Private/Templates/Search/Index.html +++ b/Resources/Private/Templates/Search/Index.html @@ -1,3 +1,4 @@ +{namespace lc=Slub\LisztCommon\ViewHelpers} {key}