Fórum
How to use custom field in content template
alex wom, modificado 12 Anos atrás.
How to use custom field in content template
Regular Member Postagens: 218 Data de Entrada: 04/05/09 Postagens Recentes
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...
Any help?
#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...
Any help?
alex wom, modificado 12 Anos atrás.
RE: How to use custom field in content template
Regular Member Postagens: 218 Data de Entrada: 04/05/09 Postagens Recentes
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?
#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?
Mayur Patel, modificado 12 Anos atrás.
RE: How to use custom field in content template
Expert Postagens: 358 Data de Entrada: 17/11/10 Postagens Recentes
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
Those are the restricted variable, Make sure that you have added property in portal-ext.properties.
journal.template.velocity.restricted.variables=
HTH, Mayur
Anil Sunkari, modificado 12 Anos atrás.
RE: How to use custom field in content template
Expert Postagens: 427 Data de Entrada: 12/08/09 Postagens Recentes
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
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