1<#assign namespace = renderResponse.getNamespace()>
2<#assign journalService = serviceLocator.findService('com.liferay.journal.service.JournalArticleService')/>
3<#assign hits = searchResultsPortletDisplayContext.getDocuments()>
4
5<div class="search__results search--locresults" id="search__results-${namespace}">
6 <div class="explore__right">
7 <div class="explore__rightinner">
8 <h2 class="explore__heading">
9 <span>Global locations</span>
10 <span class="explore__filtericon"></span>
11 </h2>
12 <div class="explore__results">
13 <div class="accordion" id="accordion-${namespace}">
14 <#if entries?has_content>
15
16 <#assign locationDetails = [] />
17 <#assign renderingCountry = "--NULL--" />
18
19 <#list entries as entry>
20 <#if !entry.isTemporarilyUnavailable()>
21
22<#assign hit = hits[entry?index] />
23<#attempt>
24 <#assign articleId = hit.get("articleId")!"" />
25 <#assign groupId = getterUtil.getLong(hit.get("groupId")!"0") />
26 <#if articleId?has_content && groupId gt 0>
27 <#assign journalArticle =
28 journalService.fetchArticle(groupId, articleId)
29 />
30 <#if journalArticle??>
31 <#assign document =
32 saxReaderUtil.read(
33 journalArticle.getContentByLocale(locale.toString())
34 )
35 />
36 <#assign rootElement = document.getRootElement() />
37 <!-- Keep existing xpath code here -->
38 </#if>
39 </#if>
40<#recover>
41</#recover>
42
43 <#if rootElement??>
44
45 <#assign xPathSelector =
46 saxReaderUtil.createXPath("dynamic-element[@name='Country']")
47 />
48
49 <#if xPathSelector??>
50
51 <#assign countryNode =
52 xPathSelector.selectSingleNode(rootElement)
53 />
54
55 <#if countryNode??>
56 <#assign country = countryNode.getStringValue()?trim />
57 <#else>
58 <#assign country = "" />
59 </#if>
60
61 </#if>
62
63</#if>
64 <#assign
65
66
67 xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='City']")
68 city = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim
69
70 xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='Address']")
71 address = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim?replace("\n", "<br/>")
72
73 xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='ContactDetails']")
74 contactDetails = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim?replace("\n", "<br/>")
75
76 xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='MapLink_TitleFieldSet']//dynamic-element[@name='MapLink_External']")
77 mapLink = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim
78
79 locationDetail = {'country': country, 'city': city, 'address': address, 'contactDetails': contactDetails, 'mapLink': mapLink}
80 />
81 <#if country == renderingCountry || renderingCountry == '--NULL--' >
82 <#assign
83 renderingCountry = country
84 locationDetails = locationDetails + [locationDetail]
85 />
86 <#else>
87 <@renderCountryLocations countryName=renderingCountry locationDetails=locationDetails />
88 <#assign
89 renderingCountry = country
90 locationDetails = [locationDetail]
91 />
92 </#if>
93 <#if entry?is_last>
94 <@renderCountryLocations countryName=country locationDetails=locationDetails />
95 </#if>
96 </#if>
97 </#list>
98 </#if>
99 </div>
100 </div>
101 </div>
102 </div>
103</div>
104
105<#macro renderCountryLocations countryName locationDetails>
106 <#assign sectionId = random.nextInt() />
107 <div class="jmaccrdn__section">
108 <div class="jmaccrdn__title" role="button" tabindex="0" data-toggle="collapse" data-target="#section${namespace}${sectionId}"
109 aria-expanded="true" aria-controls="section${namespace}${sectionId}">
110 <p>
111 ${countryName}
112 <span class="jmaccrdn__arrow"></span>
113 </p>
114 </div>
115 <div id="section${namespace}${sectionId}" class="jmaccrdn__body collapse" data-parent="#accordion-${namespace}">
116 <div class="jmaccrdn__answer-sec">
117 <#list locationDetails as locationDetail>
118 <div class="row country-locations">
119 <div class="col-md-4">
120 <div class="jmcountry-title">City</div>
121 <div>${locationDetail.city}</div>
122 </div>
123 <div class="col-md-4">
124 <div class="jmcountry-title">Address</div>
125 <div>${locationDetail.address}</div>
126 </div>
127 <div class="col-md-4">
128 <div class="jmcountry-title">Contact Details</div>
129 <div>${locationDetail.contactDetails}</div>
130 <div class="map-link-cont">
131 <a class="map-link" href="${locationDetail.mapLink}" target="_blank">Map Link</a>
132 </div>
133 </div>
134 </div>
135 </#list>
136 </div>
137 </div>
138 </div>
139</#macro>
140
141<script>
142$(function() {
143 $("#search__results-${namespace}").parent().find(".pagination-bar").hide();
144 $('button.dropdown-toggle.page-link[role="combobox"]').attr('aria-label', 'Select number of entries per page');
145});
146</script>
147
148<style>
149
150@media (min-width: 320px) and (max-width: 650px) {
151 .search__results .explore__right {
152 margin-top: -16%;
153 }
154 .search--locresults .jmaccrdn__title p {
155 font-size: 20px !important;
156 }
157 .explore__heading{
158 padding-left: 14.2px !important;
159 padding-right: 14px !important;
160 }
161 .search--locresults .jmaccrdn__title p {
162 padding: 25px 25px 25px 18px;
163 }
164}
165</style>