An error occurred while processing the template.
The following has evaluated to null or missing:
==> entries?first  [in template "20097#20125#35643" at line 45, column 37]

----
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: entriesCategoryId = entries?first.get...  [in template "20097#20125#35643" at line 45, column 17]
----
1<#-- Шаблон публикатора "Библиотека документов" --> 
2 
3<#assign assetCategoryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryLocalService") /> 
4<#assign dLAppLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLAppLocalService") /> 
5<#assign classNameService = serviceLocator.findService("com.liferay.portal.kernel.service.ClassNameLocalService") /> 
6<#assign dlUtil = staticUtil["com.liferay.document.library.kernel.util.DLUtil"]> 
7 
8<div class="knd_document_list"> 
9    <#if entries?has_content> 
10        <#assign 
11            hasNestedCategories = false 
12            parentCategoryId = 0 
13        /> 
14        <#if renderRequest.getParameter("categoryId")??> 
15            <#assign 
16                categoryId = renderRequest.getParameter("categoryId")?number?long 
17                category = assetCategoryLocalService.getCategory(categoryId) 
18            /> 
19 
20            <#if category.getParentCategoryId() != 0> 
21                <#assign 
22                    parentCategory = assetCategoryLocalService.getCategory(category.getParentCategoryId()) 
23                    parentCategoryId = parentCategory.getCategoryId() 
24                /> 
25                <h2>${parentCategory.getName()}</h2> 
26                <h3>${category.getName()}</h3> 
27            <#else> 
28                <h2>${category.getName()}</h2> 
29 
30                <#assign entriesCategoryId = entries?first.getCategoryIds()?first /> 
31                <#if entriesCategoryId != categoryId> 
32                    <#assign 
33                        hasNestedCategories = true 
34                        entriesCategory = assetCategoryLocalService.getCategory(entriesCategoryId) 
35                        parentCategoryId = entriesCategory.getParentCategoryId() 
36                    /> 
37                    <h3>${entriesCategory.getName()}</h3> 
38                </#if> 
39            </#if> 
40        <#else> 
41            <h1>Все документы</h1> 
42 
43            <#assign 
44                entries = sortDocsByCategory(entries) 
45                entriesCategoryId = entries?first.getCategoryIds()?first 
46                hasNestedCategories = true 
47                entriesCategory = assetCategoryLocalService.getCategory(entriesCategoryId) 
48            /> 
49 
50            <h2>${entriesCategory.getName()}</h2> 
51 
52        </#if> 
53        <#list entries as curEntry> 
54            <#assign classNameId = curEntry.classNameId?number /> 
55            <#assign className = classNameService.fetchByClassNameId(classNameId).value /> 
56 
57            <#if className == "com.liferay.document.library.kernel.model.DLFileEntry" > 
58                <#assign assetPk = curEntry.classPK?number /> 
59                <#assign file = dLAppLocalService.getFileEntry(assetPk) /> 
60 
61                <#assign url = dlUtil.getDownloadURL(file, file.getFileVersion(), themeDisplay, "") /> 
62                <#assign name = curEntry.getTitle(locale) /> 
63                <#assign extension = file.extension /> 
64 
65                <#if file.size < 1024 * 1024 > 
66                    <#assign size = file.size / 1024  /> 
67                    <#assign sizeLiter = "КБ"/> 
68                <#else> 
69                    <#assign size = file.size / 1024 / 1024 /> 
70                    <#assign sizeLiter = "МБ"/> 
71                </#if> 
72 
73                <#if name?ends_with("." + extension) > 
74                    <#assign name = name?keep_before_last(".") /> 
75                </#if> 
76 
77                <#if hasNestedCategories && curEntry.getCategoryIds()?first != entriesCategoryId > 
78                    <#assign 
79                        entriesCategoryId = curEntry.getCategoryIds()?first 
80                        entriesCategory = assetCategoryLocalService.getCategory(entriesCategoryId) 
81                    /> 
82 
83                    <#-- Родительская категория ранее не отображалась или изменилась --> 
84                    <#if entriesCategory.getParentCategoryId()!= 0 && entriesCategory.getParentCategoryId() != parentCategoryId > 
85                        <#assign 
86                            parentCategoryId = entriesCategory.getParentCategoryId() 
87                            parentCategory = assetCategoryLocalService.getCategory(parentCategoryId) 
88                        /> 
89                        <h2>${parentCategory.getName()}</h2> 
90                    </#if> 
91                    <h3>${entriesCategory.getName()}</h3> 
92 
93                </#if> 
94 
95                <a class="knd_document_list__item" href="${url}"> 
96                    <div class="knd_file_icon"></div> 
97                    <div class="knd_document_list__dec"> 
98                        <div class="knd_document_list__dec__name"> 
99                            ${name} 
100                        </div> 
101                        <div class="knd_text_additional"> 
102                            ${extension?upper_case} ${size?string["0.#"]} ${sizeLiter} 
103                        </div> 
104                        <div class="knd_document_list__tag_list"> 
105                            <#list curEntry.tagNames as tag> 
106                                <#if tag != 'документ'> 
107                                    <div class="label label-dismissible label-secondary" href="?tag=${tag}"> 
108                                        <span class="label-item label-item-expand"> 
109                                            ${tag} 
110                                        </span> 
111                                    </div> 
112                                </#if> 
113                            </#list> 
114                        </div> 
115                    </div> 
116                </a> 
117            </#if> 
118        </#list> 
119    </#if> 
120</div> 
121 
122<#function sortDocsByCategory entries> 
123 
124    <#assign 
125        rootCategories = [] 
126        ownCategories = [] 
127        entriesProcessed = [] 
128        entriesSorted = [] 
129    /> 
130 
131    <#list entries as entry> 
132        <#if entry.getCategories()?has_content > 
133            <#assign 
134                category = entry.getCategories()?first 
135                rootCategory = getFirstChildInTree(category) 
136            /> 
137 
138            <#if category.getCategoryId() == rootCategory.getCategoryId()> 
139                <#if !rootCategories?seq_contains(category.getCategoryId())> 
140                    <#assign rootCategories += [category.getCategoryId()] /> 
141                </#if> 
142            <#else> 
143                <#if !rootCategories?seq_contains(rootCategory.getCategoryId())> 
144                    <#assign rootCategories += [rootCategory.getCategoryId()] /> 
145                </#if> 
146 
147                <#if !ownCategories?seq_contains(category.getCategoryId())> 
148                    <#assign ownCategories += [category.getCategoryId()] /> 
149                </#if> 
150            </#if> 
151 
152            <#assign 
153                entriesProcessed += [{ 
154                    "entry": entry, 
155                    "categoryId": category.getCategoryId(), 
156                    "modifiedDate": entry.getModifiedDate() 
157                }] 
158            /> 
159        </#if> 
160    </#list> 
161 
162    <#assign 
163        rootCategories = rootCategories 
164            ?map(x -> { 
165                "id": x, 
166                "modifiedDate": assetCategoryLocalService.getAssetCategory(x).getModifiedDate() 
167            }) 
168            ?sort_by("modifiedDate") 
169    /> 
170 
171    <#assign 
172        ownCategories = ownCategories 
173            ?map(x -> { 
174                "id": x, 
175                "parentId": assetCategoryLocalService.getAssetCategory(x).getParentCategoryId(), 
176                "modifiedDate": assetCategoryLocalService.getAssetCategory(x).getModifiedDate() 
177            }) 
178    /> 
179 
180    <#list rootCategories as root > 
181        <#assign 
182            subCategories = ownCategories 
183                ?filter(x -> x.parentId == root.id) 
184                ?sort_by("modifiedDate") 
185        /> 
186 
187        <#if subCategories?has_content> 
188            <#list subCategories as sub> 
189                <#assign entriesSorted += getSortedCategoryEntries(sub, entriesProcessed) /> 
190            </#list> 
191        <#else> 
192            <#assign entriesSorted += getSortedCategoryEntries(root, entriesProcessed) /> 
193        </#if> 
194    </#list> 
195 
196    <#return entriesSorted> 
197 
198</#function> 
199 
200<#function getFirstChildInTree category > 
201    <#if category.getParentCategoryId() != 0> 
202        <#assign parent = getFirstChildInTree(category.getParentCategory()) /> 
203    <#else> 
204        <#return category /> 
205    </#if> 
206</#function> 
207 
208<#function getSortedCategoryEntries category allEntries> 
209    <#return 
210        allEntries 
211            ?filter(x -> x.categoryId == category.id) 
212            ?sort_by("modifiedDate") 
213            ?map(y -> y.entry) 
214    /> 
215</#function> 
216 
217<style> 
218    .knd_document_list h1, 
219    .knd_document_list h2, 
220    .knd_document_list h3 
221
222        margin-bottom: 1rem; 
223
224</style>