1<#-- Obtener los servicios necesarios -->
2<#assign assetCategoryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryLocalService") />
3<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
4<#assign assetVocabularyLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetVocabularyLocalService") />
5<#assign assetDisplayPageFriendlyURLProvider = serviceLocator.findService("com.liferay.asset.display.page.portlet.AssetDisplayPageFriendlyURLProvider") />
6
7<#-- Obtener el art�culo actual -->
8<#assign groupId = themeDisplay.getScopeGroupId() />
9<#assign journalArticle = journalArticleLocalService.getArticle(groupId, .vars['reserved-article-id'].data) />
10<#assign resourcePrimKey = journalArticle.getResourcePrimKey() />
11<#assign structureKey = journalArticle.getDDMStructureKey() />
12
13<#-- Obtener el autor del art�culo actual -->
14<#assign aArticleXML = saxReaderUtil.read(journalArticle.getContentByLocale(locale)) />
15<#assign authorNodes = aArticleXML.selectNodes("//dynamic-element[@name='autor']/dynamic-content") />
16<#assign authorId = "" />
17<#assign authorTitle = "" />
18
19<#assign categoriesList = assetCategoryLocalService.getCategories("com.liferay.journal.model.JournalArticle", journalArticle.getResourcePrimKey()) />
20<#assign vocabularyTopicName = "Topic" />
21
22 <#list categoriesList as category>
23 <#assign categoryVocabulary = assetVocabularyLocalService.getAssetVocabulary(category.getVocabularyId()) />
24 <#if categoryVocabulary.getName() == vocabularyTopicName>
25 <#assign categorySearch = category.getTitle(locale)/>
26 </#if>
27 </#list>
28
29<#if authorNodes?has_content>
30 <#assign authorJson = authorNodes[0].getText()?eval />
31 <#assign authorId = authorJson.classPK />
32 <#assign authorTitle = authorJson.title />
33</#if>
34
35<#-- Buscar art�culos del mismo autor y estructura -->
36<#assign relatedArticles = [] />
37<#if authorId?has_content>
38 <#assign allArticles = journalArticleLocalService.getArticlesByStructureId(groupId, structureKey, 0, 1000, null) />
39 <#list allArticles as article>
40 <#if article.getResourcePrimKey() != resourcePrimKey && !article.isInTrash() && article.getStatus() == 0>
41 <#assign articleXML = saxReaderUtil.read(article.getContentByLocale(locale)) />
42
43 <#assign articleAuthorNodes = articleXML.selectNodes("//dynamic-element[@name='autor']/dynamic-content") />
44 <#if articleAuthorNodes?has_content>
45 <#assign articleAuthorJson = articleAuthorNodes[0].getText()?eval />
46 <#if articleAuthorJson.classPK == authorId>
47 <#assign relatedArticles = relatedArticles + [article] />
48 </#if>
49 </#if>
50 </#if>
51 </#list>
52 <#assign relatedArticles = relatedArticles?sort_by("modifiedDate")?reverse />
53 <#if relatedArticles?size gt 5>
54 <#assign relatedArticles = relatedArticles[0..4] />
55 </#if>
56</#if>
57
58<#if relatedArticles?has_content>
59 <div class="container">
60 <div class="row">
61 <#list relatedArticles as curArticle>
62 <#-- Manejo de error para obtener la URL del art�culo -->
63 <#assign viewURL = "" />
64 <#attempt>
65 <#if assetDisplayPageFriendlyURLProvider??>
66 <#assign viewURL = assetDisplayPageFriendlyURLProvider.getFriendlyURL("com.liferay.journal.model.JournalArticle", curArticle.getResourcePrimKey(), themeDisplay) />
67 <#else>
68 <#assign viewURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/portal/content/" + curArticle.getGroupId() + "/" + curArticle.getArticleId() />
69 </#if>
70 <#recover>
71 <#assign viewURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/portal/content/" + curArticle.getGroupId() + "/" + curArticle.getArticleId() />
72 </#attempt>
73
74 <#assign curArticleXML = saxReaderUtil.read(curArticle.getContentByLocale(locale)) />
75 <#assign title = curArticle.getTitle(locale) />
76 <#assign tituloDestacado = curArticleXML.valueOf("//dynamic-element[@name='tituloDestacado']/dynamic-content") />
77 <#assign imagenArticulo = curArticleXML.valueOf("//dynamic-element[@name='imagen']/dynamic-content/text()") />
78 <#assign detalle = curArticleXML.valueOf("//dynamic-element[@name='detalle']/dynamic-content") />
79 <#-- Featured Image of the Article -->
80 <#assign featuredImage = curArticle.getArticleImageURL(themeDisplay)!""/>
81
82 <#assign categoriesList = assetCategoryLocalService.getCategories("com.liferay.journal.model.JournalArticle", curArticle.getResourcePrimKey())/>
83 <#assign vocabularyTemaName = "Tema" />
84 <#assign vocabularyNRevistaName = "N� de revista" />
85
86 <#if categoriesList?has_content>
87 <#list categoriesList as category>
88 <#assign categoryVocabulary = assetVocabularyLocalService.getAssetVocabulary(category.getVocabularyId()) />
89 <#if categoryVocabulary.getName() == vocabularyTopicName>
90 <#if categorySearch == category.getTitle(locale)>
91 <div class="col-md">
92 <article class="article article-review">
93 <figure class="media">
94 <picture>
95 <#-- show featuredImage if set. -->
96 <#if featuredImage?has_content>
97 <img src="${featuredImage}" />
98 <#else>
99 <#if imagenArticulo?? && imagenArticulo?has_content>
100 <#attempt>
101 <#assign jsonObject = imagenArticulo?eval/>
102 <#assign entryUuid = jsonObject.uuid />
103 <#assign entryGroupId = getterUtil.getLong(jsonObject.groupId) />
104 <#assign entryAlt = jsonObject.alt />
105 <#assign dlFileEntryLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService") />
106 <#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService")>
107 <#assign dlFileEntry = dlFileEntryLocalService.getDLFileEntryByUuidAndGroupId(entryUuid, entryGroupId) />
108 <#assign assetEntry = assetEntryLocalService.getEntry("com.liferay.document.library.kernel.model.DLFileEntry", dlFileEntry.fileEntryId) />
109 <#assign assetRenderer = assetEntry.assetRenderer />
110 <#assign imagen = assetRenderer.getURLDownload(themeDisplay) />
111 <img alt="${entryAlt}" data-fileentryid="${dlFileEntry.fileEntryId}" src="${imagen}" />
112 <#recover>
113 </#attempt>
114 </#if>
115 </#if>
116 </picture>
117 </figure>
118
119 <p class="author">
120 <a title=${authorTitle}>${authorTitle}</a>
121 </p>
122
123 <#-- No es necesario para rese�as
124 <p class="kicker">
125 <#if categoriesList?has_content>
126 <#list categoriesList as category>
127 <#assign categoryVocabulary = assetVocabularyLocalService.getAssetVocabulary(category.getVocabularyId()) />
128 <#if categoryVocabulary.getName() == vocabularyTemaName || categoryVocabulary.getName() == vocabularyNRevistaName>
129 <a title="${category.getTitle(locale)}">${category.getTitle(locale)}</a>
130 </#if>
131 </#list>
132 </#if>
133 </p>
134 -->
135
136 <h2 class="title title-standard">
137 <a href="${viewURL}" title="${title}">${title}</a>
138 </h2>
139
140 <#-- No es necesario para rese�as
141 <p class="meta">
142 <#assign fecha = dateUtil.getDate(curArticle.getDisplayDate(), "d 'de' MMMM 'de' yyyy", locale) />
143 <#if fecha?has_content>
144 <span>${fecha}</span>
145 </#if>
146
147 <#assign tiempo = "" />
148 <#if detalle?has_content>
149 <#assign content = detalle?trim />
150 <#if content != "">
151 <#assign contentCount = content?replace("<[^>]+>", "", "r")?word_list?size />
152 <#if contentCount gt 0>
153 <#assign minutesValue = (contentCount/200)?round />
154 <#if minutesValue == 0>
155 <#assign tiempo = "Unos segundos" />
156 <#elseif minutesValue == 1>
157 <#assign tiempo = minutesValue + " minuto" />
158 <#else>
159 <#assign tiempo = minutesValue + " minutos" />
160 </#if>
161 </#if>
162 </#if>
163 </#if>
164 <#if tiempo?? && tiempo != "">
165 <span><i class="fa fa-regular fa-clock"></i> ${tiempo}</span>
166 </#if>
167 </p>
168 -->
169
170
171 </article>
172 </div>
173 </#if>
174 </#if>
175
176 </#list>
177 </#if>
178
179
180 </#list>
181 </div>
182 </div>
183<#else>
184 <#-- No se encontraron relacionados -->
185 <div class="text"><p>No se han encontrado articulos relacionados</p></div>
186</#if>
187
188<style>
189/* default image size TODO: fix in theme, this is a temporal workaround. */
190.nuestro-tiempo .article.article-review .media{
191 height: initial;
192}
193</style>