News search results
Bilah Pencarian
Pencarian Hasil
Kesalahan terjadi ketika Memproses Template.
The string doesn't match the expected date/time/date-time format. The string to parse was: "19 Des 24 14:05". The expected format was: "dd/MM/yyyy hh:mm a". The nested reason given follows: Unparseable date: "19 Des 24 14:05" ---- FTL stack trace ("~" means nesting-related): - Failed at: ${entry.getCreationDateString()?datet... [in template "20099#20135#93644519" at line 176, column 49] ----
1<#-- DDM Template Key: "NEWS-SEARCH-RESULTS-LIST-FTL" -->
2<#assign JOURNAL_ARTICLE_CLASS_NAME = "com.liferay.journal.model.JournalArticle" />
3<#-- assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
4<#assign article = journalArticleLocalService.fetchLatestArticle(entry.getClassPK()) /-->
5
6<#-- ${journalArticleLocalService} -->
7<#-- ${article} -->
8
9
10
11<#-- ----------------------------------------------------------------------- -->
12<#-- Init Logger -->
13<#-- ----------------------------------------------------------------------- -->
14
15<#assign log = objectUtil("com.liferay.portal.kernel.log.LogFactoryUtil").getLog("webcms.portal.template.widget.news-search-result-list") />
16
17
18<#-- Categories -->
19<#assign journalArticleResourceLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleResourceLocalService") />
20<#assign assetCategoryLocalServiceUtil = staticUtil["com.liferay.asset.kernel.service.AssetCategoryLocalServiceUtil"] />
21<#assign assetVocabularyLocalServiceUtil = staticUtil["com.liferay.asset.kernel.service.AssetVocabularyLocalServiceUtil"] />
22
23<#assign searchResults = [] />
24<#if searchContainer?has_content>
25 <#assign searchResults = searchContainer.getResults()![] />
26 <#if searchResults?has_content>
27 </#if>
28</#if>
29
30<#assign searchResultsDocuments = [] />
31<#if searchResultsPortletDisplayContext?has_content>
32 <#assign searchResultsDocuments = searchResultsPortletDisplayContext.getDocuments()![] />
33 <#if searchResultsDocuments?has_content>
34 <!-- searchResultsDocuments.size : ${searchResultsDocuments?size} -->
35 </#if>
36</#if>
37
38<#assign newsCategoryNames = [] />
39<#assign newsVocabName = "news categories" />
40<#assign newsVocabId = -1 />
41<#assign newsVocab = "" />
42<#assign newsCategories = [] />
43<#assign categories = [] />
44
45<#-- Vars -->
46<#attempt>
47 <#assign newsVocabId = findAssetVocabularyIdByName(newsVocabName, -1) />
48 <#assign newsVocab = assetVocabularyLocalServiceUtil.getAssetVocabulary(newsVocabId) />
49
50 <#if newsVocab?has_content>
51 <#assign newsCategories = newsVocab.getCategories() />
52 </#if>
53
54 <#if newsCategories?has_content>
55 <#if newsCategories?size gt 0>
56 <#list newsCategories as newsCategory>
57 <#assign newsCategoryNames = newsCategoryNames + [newsCategory.name] />
58 </#list>
59 </#if>
60 </#if>
61<#recover>
62</#attempt>
63
64
65<div id="searchFilterContainer">
66 <#-- dynamic placement of search filters on mobile -->
67</div>
68
69<p class="search-total-label text-default">
70 We found <strong>${searchContainer.getTotal()}</strong>
71<#if searchResultsPortletDisplayContext.getKeywords()?trim?length > 0>
72 results for <strong>${htmlUtil.escape(searchResultsPortletDisplayContext.getKeywords())}</strong>.
73<#else>
74 results.
75</#if>
76</p>
77
78<#-- ---------------------------------- -->
79<#-- Render search results news -->
80<#-- ---------------------------------- -->
81
82<div class="display-list lfr-search-container-wrapper">
83 <#if entries?has_content>
84 <#list entries as entry>
85 <#-- if entry?has_content-->
86
87 <#-- DOE CHANGE START -->
88 <#if entry?has_content>
89 ${log.info("entry index : " + entry?index)}
90 ${log.info("entry.title : " + (entry.getTitle())!"")}
91 ${log.info("entry.iconId : " + (entry.getIconId())!"")}
92 ${log.info("entry.className : " + (entry.getClassName())!"")}
93 ${log.info("entry.classPK : " + (entry.getClassPK())!"")}
94 ${log.info("entry.resourceImage : " + (entry.getResourceImage())!"")}
95 </#if>
96
97 <#assign searchDocument = "" />
98 <#if entry?has_content>
99 <#if searchResults?has_content>
100 <#assign entryIndex = entry?index />
101 <#assign searchDocument = searchResults[entryIndex] />
102 <#-- searchDocument ${entryIndex} : ${searchDocument} : entry- ${entry} -->
103 </#if>
104 </#if>
105
106 <#assign categories = getSearchDocumentFieldValue(searchDocument, "assetCategoryTitles", "") />
107 <#assign articleId = getSearchDocumentFieldValue(searchDocument, "articleId", "") />
108 <#assign resourceImage = getSearchDocumentFieldValue(searchDocument, "ddm__.*resourceImage.*", "") />
109 <#assign dateCreated = getSearchDocumentFieldValue(searchDocument, "ceateDate","") />
110
111
112
113 <#if articleId?has_content>
114 ${log.info("articleId : " + articleId)}
115
116 <#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService" ) />
117
118 ${log.info("journalArticleLocalService : " + journalArticleLocalService)}
119 <#assign articleResourcePK = journalArticleResourceLocalService.getArticleResourcePrimKey(groupId,articleId) />
120
121 <#assign categoryList = assetCategoryLocalServiceUtil.getCategories("com.liferay.journal.model.JournalArticle",articleResourcePK) />
122
123 <#-- <#assign article = journalArticleLocalService.getArticle(getterUtil.getLong(groupId), articleId) /> -->
124 </#if>
125
126 <div class="card mb-4 pb-3 w-100 border-top-0 border-left-0 border-right-0 border-bottom rounded-0">
127 <div class="row no-gutters m-0">
128 <#if resourceImage?has_content>
129 <#assign removePadding = "px-sm-3" />
130 <#assign removePaddingTitle = "pl-sm-3" />
131 <div class="col-12 col-sm-3 col-lg-2 p-0">
132 <#-- ${log.info("resourceImage : " + resourceImage)} -->
133 <#assign imageParams = "f_auto" />
134 <#assign imagePath = resourceImage />
135 <#assign imageSrc = buildCloudinaryImageUrl(imageParams, imagePath) />
136 <#-- ${log.debug("imageSrc : " + imageSrc)} -->
137 <#assign escapedImageSrc = htmlUtil.escapeHREF(imageSrc) />
138 <#-- ${log.debug("escapedImageSrc : " + escapedImageSrc)} -->
139 <img class="news-search__image img-fluid" alt="" src="${escapedImageSrc}" />
140 </div>
141
142 <div class="col-12 col-sm-9 col-lg-10 p-0">
143 <#else>
144 <#assign removePadding = "" />
145 <#assign removePaddingTitle = "" />
146 <div class="col-12 p-0">
147 </#if>
148
149 <div class="card-body ${removePaddingTitle} pt-sm-0 pt-2 p-0 d-flex flex-column flex-sm-row justify-content-sm-between align-items-start">
150 <h5 class="card-title mt-2 mt-sm-0 mb-0 order-2 order-sm-1">
151 <a href="${entry.getViewURL()}">
152 ${entry.getHighlightedTitle()}
153 </a>
154 </h5>
155 <#-- Loop through all categories assigned to the news article -->
156 <div class="categories order-1 order-sm-2 text-sm-right flex-shrink-sm-0 ml-sm-4 ml-0">
157 <#list categoryList as categoryListing>
158 <#assign vocabularyId = categoryListing.getVocabularyId() />
159 <#-- Set the ID for the News section vocabulary -->
160 <#-- if vocabularyId == 379886 -->
161 <span class="mb-0 news__category ${categoryListing.getName()?replace(' ','-')?lower_case} news__category-${newsCategoryNames?seq_index_of(categoryListing.getName())}">${categoryListing.getName()}</span>
162 <#--</#if-->
163 </#list>
164 </div>
165 </div>
166
167 <div class="card-body ${removePadding} py-0 px-0 ">
168 <#if entry.isCreationDateVisible() && entry.getCreationDateString()?has_content>
169
170
171 <p class="card-text mb-1">
172 <small class="font-weight-bold">
173 <#setting date_format="dd MMMM yyyy">
174<#setting locale="en_AU">
175
176 ${entry.getCreationDateString()?datetime("dd/MM/yyyy hh:mm a")?date}</small>
177
178 </p>
179 </#if>
180 <p class="card-text">${entry.getContent()}</p>
181 </div>
182
183 </div>
184 </div>
185 </div>
186 </#list>
187 </#if>
188
189</div>
190
191<#-- ----------------------------------------------------------------------- -->
192<#-- Functions -->
193<#-- ----------------------------------------------------------------------- -->
194
195<#--
196-- Returns the first value matching the search results docment field name by regex, otherwise the defaultValue is returned.
197--
198-- The search document must be of type "com.liferay.portal.kernel.search.Document"
199--
200-- @see com.liferay.portal.kernel.search.Document
201-->
202<#function getSearchDocumentFieldValue searchDocument regex defaultValue>
203 ${log.info("getSearchDocumentFieldValue ...")}
204 ${log.info("searchDocument : " + searchDocument)}
205 ${log.info("regex : " + regex)}
206 ${log.info("defaultValue : " + defaultValue)}
207
208 <#assign fieldValueResult = defaultValue />
209 <#attempt>
210 <#if searchDocument?has_content && regex?has_content>
211 <#assign searchDocumentFields = searchDocument.getFields() />
212 <#if searchDocumentFields?has_content>
213 <#list searchDocumentFields as fieldKey, fieldValue>
214 <#if fieldKey?has_content>
215 <#assign fieldName = fieldKey />
216 <#if fieldName?matches(regex)>
217 <#assign fieldValueResult = (searchDocument.get(fieldKey))!defaultValue />
218 <#break>
219 </#if>
220 </#if>
221 </#list>
222 </#if>
223 </#if>
224 <#recover>
225 <#-- NO-OP -->
226 </#attempt>
227
228 ${log.info("getSearchDocumentFieldValue : " + fieldValueResult)}
229 <#return fieldValueResult>
230</#function>
231
232<#function findAssetVocabularyIdByName vocabName defaultVocabId>
233 <#assign assetVocabularyId = defaultVocabId />
234
235 <#attempt>
236 <#assign assetVocabList = assetVocabularyLocalServiceUtil.getAssetVocabularies(0, staticFieldGetter.getFieldValue("java.lang.Integer", "MAX_VALUE")) />
237 <#if assetVocabList?has_content>
238 <#list assetVocabList as assetVocabItem>
239 <#assign assetVocabItemName = assetVocabItem.getName() />
240 <#if assetVocabItemName?lower_case == vocabName?lower_case >
241 <#assign assetVocabularyId = assetVocabItem.getVocabularyId() />
242 </#if>
243 </#list>
244 </#if>
245 <#recover>
246 <#assign assetVocabularyId = defaultVocabId />
247 </#attempt>
248
249 <#return assetVocabularyId>
250</#function>
251
252<#function buildCloudinaryImageUrl imageParams imagePath>
253 <#assign cloudinaryImageUrl = "" />
254 <#attempt>
255 <#if imageParams?has_content && imagePath?has_content>
256 <#assign cloudinaryBaseUrl = webcms.getCloudinaryPath() />
257 <#if !cloudinaryBaseUrl?ends_with("/")>
258 <#assign cloudinaryBaseUrl = cloudinaryBaseUrl + "/" />
259 </#if>
260 <#if !imagePath?starts_with("/")>
261 <#assign imagePath = "/" + imagePath />
262 </#if>
263 <#assign cloudinaryImageUrl = cloudinaryBaseUrl + imageParams + imagePath />
264 </#if>
265 <#recover>
266 <#-- NO-OP -->
267 </#attempt>
268
269 <#return cloudinaryImageUrl>
270</#function>