Foros de discusión

velocity template get assetEntry

andres digiovanni, modificado hace 11 años.

velocity template get assetEntry

New Member Mensajes: 14 Fecha de incorporación: 18/09/12 Mensajes recientes
Hi!

I'm developping a web content template. I'm trying to get the ID of a AssetEntry but I can't get the attributs.


My code is :
#set ($assetEntryLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService"))
#set ($assetEntry = $assetEntryLocalService.getEntry("com.liferay.portlet.journal.model.JournalArticle", $resourceprimKey))

$assetEntry



When I print $assetEntry I get:

{entryId=11731, groupId=10528, companyId=10154, userId=10196, userName=Test Test, createDate=Fri Feb 15 09:16:17 GMT 2013, modifiedDate=Thu Feb 21 10:47:54 GMT 2013, classNameId=10108, classPK=11729, classUuid=0b9aeff3-63b8-4ac6-9db3-fa7dfafbbd70, classTypeId=11703, visible=true, startDate=null, endDate=null, publishDate=Fri Feb 15 09:15:00 GMT 2013, expirationDate=null, mimeType=text/html, title=, description=, summary=, url=, layoutUuid=, height=0, width=0, priority=0.0, viewCount=432} 


This is a table row.

How can I get the entryId's value? I try to use the functions getEntryId(), split(","), ...... But doesn't work!

Edit: I'm using liferay 6.1.1

If anyone knows how to solve this problem I be gratefull.

Thanks!
Andrew
thumbnail
Juhi Kumari, modificado hace 11 años.

RE: velocity template get assetEntry

Expert Mensajes: 347 Fecha de incorporación: 12/12/11 Mensajes recientes
Hi,

Your $resourceprimKey is 0 so you are not getting $assetEntry.
I set value for $resourceprimKey then its wirking fine.
BTW from where you are getting $resourceprimKey ???

Regards
Juhi
andres digiovanni, modificado hace 11 años.

RE: velocity template get assetEntry

New Member Mensajes: 14 Fecha de incorporación: 18/09/12 Mensajes recientes
Hi,

I put all the code:

#set ($groupId = $themeDisplay.getLayout().getGroupId())

#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($ja = $journalArticleLocalService.getArticle( $groupId, $reserved-article-id.data ))
#set ($resourceprimKey = $ja.getResourcePrimKey())

#set ($assetEntryLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService"))
#set ($assetEntry = $assetEntryLocalService.getEntry("com.liferay.portlet.journal.model.JournalArticle", $resourceprimKey))

$assetEntry



The $resourceprimKey is diferent to 0. It has the correct value.

$assetEntry has the values I need but I can't access in it.


Regards,
Andrew
thumbnail
Juhi Kumari, modificado hace 11 años.

RE: velocity template get assetEntry

Expert Mensajes: 347 Fecha de incorporación: 12/12/11 Mensajes recientes
Hi,
Replace your 4th line with this
#set ($ja = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId),$getterUtil.getString($reserved-article-id.data)))

Now it will work.

Regards
Juhi
thumbnail
James Falkner, modificado hace 11 años.

RE: velocity template get assetEntry

Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
andres digiovanni:


$assetEntry has the values I need but I can't access in it.


You should be able to call $assetEntry.getEntryId() - if that does not work then something has gone horribly wrong emoticon Also, make sure you uncheck 'cacheable' when editing the template.
andres digiovanni, modificado hace 11 años.

RE: velocity template get assetEntry

New Member Mensajes: 14 Fecha de incorporación: 18/09/12 Mensajes recientes
I tried to use the methods getEntryId() but doesn't work. I don't know what has gone wrong.

I try your solution Juhi Kumari, but doesn't work.

Anyone has gone a similar error?

Thank you for the answers!
Andrew
thumbnail
Juhi Kumari, modificado hace 11 años.

RE: velocity template get assetEntry

Expert Mensajes: 347 Fecha de incorporación: 12/12/11 Mensajes recientes
Hi,

Did you put this line in your portal-ext.properties ???
journal.template.velocity.restricted.variables=


Regards
Juhi
andres digiovanni, modificado hace 11 años.

RE: velocity template get assetEntry

New Member Mensajes: 14 Fecha de incorporación: 18/09/12 Mensajes recientes
Hi!

It works!

I modified the portal-ext.properties.

Juhi Kumari:
Hi,

Did you put this line in your portal-ext.properties ???
journal.template.velocity.restricted.variables=


Regards
Juhi



I had this:

journal.template.velocity.restricted.variables=true


And I replaced it for:

journal.template.velocity.restricted.variables=



I don't understand why the others methods works fine.

Thanks everybody for the answers!!

Regards,
Andrew
Devendra Patel, modificado hace 11 años.

Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry

Junior Member Mensajes: 71 Fecha de incorporación: 26/09/11 Mensajes recientes
Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel, modificado hace 11 años.

Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry

Junior Member Mensajes: 71 Fecha de incorporación: 26/09/11 Mensajes recientes
Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel, modificado hace 11 años.

Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry

Junior Member Mensajes: 71 Fecha de incorporación: 26/09/11 Mensajes recientes
Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel, modificado hace 11 años.

Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry

Junior Member Mensajes: 71 Fecha de incorporación: 26/09/11 Mensajes recientes
Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel, modificado hace 11 años.

Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry

Junior Member Mensajes: 71 Fecha de incorporación: 26/09/11 Mensajes recientes
Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
thumbnail
Pravin Pawar, modificado hace 10 años.

RE: velocity template get assetEntry

Junior Member Mensajes: 62 Fecha de incorporación: 17/11/09 Mensajes recientes
James,

$assetEntry.getEntryId(). It's working fine
Devendra Patel, modificado hace 11 años.

RE: velocity template get assetEntry

Junior Member Mensajes: 71 Fecha de incorporación: 26/09/11 Mensajes recientes
Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel