Last active
July 22, 2025 02:23
-
-
Save prince-neres/4469abf38fcd6de3a8223e355b864b80 to your computer and use it in GitHub Desktop.
Get contents with resourceLocator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="administrative-act"> | |
| [#assign assetCategoryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryLocalService") /] | |
| [#assign currentUrl = themeDisplay.getURLCurrent() /] | |
| [#attempt] | |
| [#assign | |
| actCategoryId = currentUrl?split("/")?last?number | |
| actCategory = assetCategoryLocalService.getCategory(actCategoryId) | |
| /] | |
| [#recover] | |
| <h2>Erro ao processar conteúdos de ato.</h2> | |
| [/#attempt] | |
| [#if actCategory??] | |
| [#assign actStructureId = configuration.actStructureId /] | |
| [#assign | |
| structuredContentResource = resourceLocator.locate("/headless-delivery/v1.0", "StructuredContent") | |
| structuredContents = structuredContentResource.getContentStructureStructuredContentsPage(actStructureId, null, null, structuredContentResource.toFilter("taxonomyCategoryIds/any(t:t eq ${actCategoryId})"), null, null) | |
| structuredContents = structuredContents.getItems() | |
| /] | |
| [#assign contentsByCategory = jsonFactoryUtil.createJSONObject()] | |
| [#list structuredContents as structuredContent] | |
| [#list structuredContent.taxonomyCategoryBriefs as category] | |
| [#assign categoryName = category.taxonomyCategoryName /] | |
| [#if contentsByCategory.has(categoryName)] | |
| [#assign | |
| existingArray = contentsByCategory.getJSONArray(categoryName) | |
| updatedArray = existingArray.put(structuredContent) | |
| contentsByCategory = contentsByCategory.put(categoryName, updatedArray) | |
| /] | |
| [#else] | |
| [#assign | |
| newArray = jsonFactoryUtil.createJSONArray() | |
| newArray = newArray.put(structuredContent) | |
| contentsByCategory = contentsByCategory.put(categoryName, newArray) | |
| /] | |
| [/#if] | |
| [/#list] | |
| [/#list] | |
| [#list contentsByCategory.keys() as categoryName] | |
| [#if (categoryName != "Diretrizes") && (categoryName != "Documentos norteadores") && (categoryName != "Instruções normativas") && (categoryName != "Notas técnicas") && (categoryName != "Pareceres PGF") && (categoryName != "Políticas") && (categoryName != "Portarias") && (categoryName != "Regimentos") && (categoryName != "Regulamentos") && (categoryName != "Resoluções")] | |
| <div class="mb-3 d-flex flex-column"> | |
| <h2 class="font-weight-normal mb-2"> | |
| ${categoryName} | |
| </h2> | |
| [#list 0..contentsByCategory.getJSONArray(categoryName).length() - 1 as contentIndex] | |
| [#assign content = contentsByCategory.getJSONArray(categoryName).get(contentIndex) /] | |
| <a class="mb-3" href="${content.contentFields[1].contentFieldValue.data}"> | |
| ${content.title} | |
| <span> | |
| - ${content.contentFields[2].contentFieldValue.data} | |
| </span> | |
| </a> | |
| [/#list] | |
| </div> | |
| [/#if] | |
| [/#list] | |
| [/#if] | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment