Category Filter

An error occurred while processing the template.
The following has evaluated to null or missing:
==> categoryCounter  [in template "29173645033645#730199#1110071" at line 63, column 31]

----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: #assign categoryUsages = categoryCoun...  [in template "29173645033645#730199#1110071" in macro "displayCategoryLink" at line 63, column 5]
	- Reached through: @displayCategoryLink category, active...  [in template "29173645033645#730199#1110071" in macro "displayCategories" at line 55, column 17]
	- Reached through: @displayCategories categories, active...  [in template "29173645033645#730199#1110071" in macro "renderVocabularyCategories" at line 38, column 5]
	- Reached through: @renderVocabularyCategories vocabular...  [in template "29173645033645#730199#1110071" at line 30, column 13]
----
1<#-- @ftlvariable name="entries" type="java.util.List<com.liferay.asset.kernel.model.AssetVocabulary>" --> 
2<#-- @ftlvariable name="assetCategoryPropertyLocalService" type="com.liferay.asset.category.property.service.AssetCategoryPropertyLocalService" --> 
3<#-- @ftlvariable name="categoryCounter" type="ru.pragmatic.liferay.category.counter.api.CategoryCounter" --> 
4 
5<style> 
6    .cat-items { 
7        row-gap: 12px; 
8    } 
9    .category-empty, 
10    .category-usages { 
11        display: none; 
12    } 
13    .has-control-menu .category-empty, 
14    .has-control-menu .category-usages { 
15        display: initial; 
16    } 
17    .has-control-menu.controls-hidden .category-empty, 
18    .has-control-menu.controls-hidden .category-usages { 
19        display: none; 
20    } 
21</style> 
22 
23<#if entries?has_content> 
24    <#assign activeCategoryId = (renderRequest.getParameter('categoryId')?number)!0 /> 
25    <div class="pragm_categories_wrapper"> 
26        <#list entries as vocabulary> 
27            <h2 class="categories_title"> 
28                ${vocabulary.getUnambiguousTitle(entries, themeDisplay.getSiteGroupId(), themeDisplay.getLocale())} 
29            </h2> 
30            <@renderVocabularyCategories vocabulary.getCategories()/> 
31        </#list> 
32    </div> 
33</#if> 
34 
35<#macro renderVocabularyCategories categories> 
36    <#assign activeCategory = getCategoryById(categories,activeCategoryId)!{}/> 
37    <#assign activeVocabularyCategoryId = activeCategory?has_content?then(activeCategoryId,0)/> 
38    <@displayCategories categories activeVocabularyCategoryId /> 
39</#macro> 
40 
41<#macro displayCategories categories layerCategoryId activeChildCategoryId=0> 
42    <#if layerCategoryId != 0> 
43        <#local displayCategoriesLayer = getCategories(categories,layerCategoryId)/> 
44        <#local layerCategory = getCategoryById(categories,layerCategoryId)/> 
45        <#local parentCategoryId = layerCategory.getParentCategoryId()!0/> 
46        <@displayCategories categories parentCategoryId layerCategoryId/> 
47    <#else> 
48        <#local parentCategoryId = 0/> 
49        <#local displayCategoriesLayer = getCategories(categories,0)/> 
50    </#if> 
51 
52    <#if displayCategoriesLayer?has_content> 
53        <ul class="cat-items"> 
54            <#list displayCategoriesLayer as category> 
55                <@displayCategoryLink category activeChildCategoryId /> 
56            </#list> 
57        </ul> 
58    </#if> 
59</#macro> 
60 
61<#macro displayCategoryLink category layerCategoryId> 
62    <#local categoryId = category.getCategoryId() /> 
63    <#assign categoryUsages = categoryCounter.countEntriesWithCategory(themeDisplay, categoryId) /> 
64    <#if categoryUsages gt 0 || themeDisplay.isSignedIn()> 
65        <#local categoryURL = portletURLFactory.create(renderRequest, portletDisplay.getId(), "VIEW" ) /> 
66 
67        ${categoryURL.setParameter("resetCur", "true")} 
68 
69        <#if activeCategoryId == categoryId> 
70            <#local linkClass="active"/> 
71            ${categoryURL.setParameter("categoryId", "")} 
72        <#else> 
73            ${categoryURL.setParameter("categoryId", categoryId?string + "")} 
74            <#if layerCategoryId == categoryId> 
75                <#local linkClass="active_parent"/> 
76            <#else> 
77                <#local linkClass=""/> 
78            </#if> 
79        </#if> 
80        <#assign itemClass = (categoryUsages gt 0)?then("", "category-empty") /> 
81 
82        ${categoryURL.setParameter("scroll", "portlet_" + portletDisplay.getId())} 
83        <li <#if itemClass?has_content>class="${itemClass}"</#if>> 
84            <a <#if linkClass?has_content>class="${linkClass}"</#if> href="${categoryURL}"> 
85                ${category.getName()} 
86                <#if themeDisplay.isSignedIn()> 
87                    <span class="category-usages">(${categoryUsages})</span> 
88                </#if> 
89            </a> 
90        </li> 
91    </#if> 
92</#macro> 
93 
94<#function getCategories categories parentCategoryIdF> 
95    <#local displayCategories = categories?filter(category -> category.getParentCategoryId() == parentCategoryIdF) > 
96 
97    <#local displayCategoriesMap = {}> 
98 
99    <#list displayCategories as category> 
100        <#attempt> 
101            <#local categoryOrderProperty = assetCategoryPropertyLocalService.fetchCategoryProperty(category.getCategoryId(), 'order')!{} > 
102            <#if categoryOrderProperty?has_content> 
103                <#local orderValue = categoryOrderProperty.getValue() > 
104            <#else> 
105                <#local orderValue = '0' > 
106            </#if> 
107            <#recover> 
108                <#local orderValue = '0' > 
109        </#attempt> 
110 
111        <#local key = orderValue + '_' + category.getName()> 
112 
113        <#local displayCategoriesMap += {key: category}> 
114    </#list> 
115 
116    <#local displayCategoriesList = []> 
117 
118    <#list displayCategoriesMap?keys?sort as key> 
119        <#local displayCategoriesList =  displayCategoriesList + [displayCategoriesMap[key]]> 
120    </#list> 
121 
122    <#return displayCategoriesList> 
123</#function> 
124 
125<#function getCategoryById categories categoryId> 
126    <#return categories?filter(category -> category.getCategoryId() == categoryId)?first> 
127</#function>