Diferencia entre revisiones de «Custom Fields en Liferay»

De Dos Ideas.
Saltar a: navegación, buscar
(Web Content)
(Obteniendo un custom field de sitio desde un template)
 
Línea 25: Línea 25:
 
</code>
 
</code>
  
=== Obteniendo un custom field de sitio desde un template ===
+
=== Obteniendo un custom field de sitio desde un WebContent===
 
<code>
 
<code>
 
## GroupId.
 
## GroupId.

Revisión actual del 18:15 15 abr 2014

Esta utilidad permite definir variables propias dentro de determinados recursos, por ejemplo sitio, pagina, usuario, etc. Estas variables se exponen mediante Liferay’s ExpandoService.

Web Content

En este ejemplo se muestra como acceder, mediante Velocity, al Custom Field --fecha-- definido dentro del recurso Web Content.

    1. Servicio para buscar los artículos publicados.
  1. set ($journalArticleLocalService = $serviceLocator.findService('com.liferay.portlet.journal.service.JournalArticleLocalService'))
    1. GroupId.
  1. set($groupId = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
    1. Retorna el articulo actual.
  1. set ($currentArticle = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId), $reserved-article-id.data, $getterUtil.getDouble($reserved-article-version.data)))
    1. companyId.
  1. set ($companyId = $getterUtil.getLong($request.theme-display.company-id))
    1. ExpandoService, retorna el valor del custom field --fecha-- del --currentArticle--.
  1. set($fecha = $expandoValueLocalService.getData($companyId, "com.liferay.portlet.journal.model.JournalArticle", "CUSTOM_FIELDS", "fecha", $currentArticle.id))

Texto: $text.data -- Fecha: $fecha

Obteniendo un custom field de sitio desde un WebContent

    1. GroupId.
  1. set($groupId = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
    1. companyId.
  1. set ($companyId = $getterUtil.getLong($request.theme-display.company-id))
    1. ExpandoService, retorna el valor del custom field --EsIntranet-- del --sitio--.
  1. set($esIntranet = $expandoValueLocalService.getData($companyId, "com.liferay.portal.model.Group", "CUSTOM_FIELDS", "EsIntranet",$groupId))

Es Intranet: $esIntranet

Ver también

Wiki oficial de Liferay