Foros de discusión

How to use custom field in content template

thumbnail
alex wom, modificado hace 12 años.

How to use custom field in content template

Regular Member Mensajes: 218 Fecha de incorporación: 4/05/09 Mensajes recientes
I would like to use journal article custom field in content template, I don't know if it is the right way to do this, but I tried to access the JournalArticle in this way:

#set($articleService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set($article = $articleService.getArticle($$group_id,$reserved-article-id.data))
#set($myData = $article.getExpandoBridge().getAttribute("my_data"))

After this I tried to display myData simply in this way:
<p>$myData</p>

But it doesn't work... emoticon

Any help?
thumbnail
alex wom, modificado hace 12 años.

RE: How to use custom field in content template

Regular Member Mensajes: 218 Fecha de incorporación: 4/05/09 Mensajes recientes
I tried another way in template:

#set($myData =$expandoValueLocalService.getData($company_id, "com.liferay.portlet.journal.model.JournalArticle", "CUSTOM_FIELDS", "my_data", $reserved-article-id.data))

<p>$myData</p>

And also this doesn't work. First of all I don't know if it is correct to use $myData in html in that way, because it display $myData it doesn't try to intepret the velocity variable.
Another doubt is how to use expandoValueLocalService, in this wiki I found that expandoValueLocalService is an accessible object from velocity, but there is not an example.

Any suggestion?
thumbnail
Mayur Patel, modificado hace 12 años.

RE: How to use custom field in content template

Expert Mensajes: 358 Fecha de incorporación: 17/11/10 Mensajes recientes
Hi alex,

Those are the restricted variable, Make sure that you have added property in portal-ext.properties.

journal.template.velocity.restricted.variables=

HTH, Mayur
thumbnail
Anil Sunkari, modificado hace 12 años.

RE: How to use custom field in content template

Expert Mensajes: 427 Fecha de incorporación: 12/08/09 Mensajes recientes
Hi Alex,

Try like mentioned below ...it may help you out!
#set($articleService = $serviceLocator.findService("com.liferay.portlet.expando.service.ExpandoValueLocalServiceUtil"))
#set($article = $articleService.getColumnValues($$group_id,$reserved-article-id.data)) (Refer : getColumnValues(
long companyId, long classNameId, java.lang.String tableName,
java.lang.String columnName, int start, int end)
) in ExpandoValueLocalServiceUtil class.

Regards,
Anil Sunkari