Foren

How to get Related Assets of web content in custom web content template ?

thumbnail
Tejas Kanani, geändert vor 10 Jahren.

How to get Related Assets of web content in custom web content template ?

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Hi,

I want to get all the Related Assets that I've relate to my web content in my custom template. I've checked all the reserved variables set for Web Content but not able to get the one which returns me the Related Assets list.

Can anyone any idea how can we get the same ?

Thanks,
Tejas
thumbnail
Vilmos Papp, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 529 Beitrittsdatum: 21.10.10 Neueste Beiträge
Hi Tejas,

Based on related_assets.jsp you can have it by using input-asset-links tag (or redo it's logic in your custom portlet):


<%
JournalArticle article = (JournalArticle)request.getAttribute(WebKeys.JOURNAL_ARTICLE);

long assetEntryId = 0;
long classPK = 0;

if (article != null) {
	classPK = article.getResourcePrimKey();

	if (!article.isApproved() && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT)) {
		AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(JournalArticle.class.getName(), article.getPrimaryKey());

		if (assetEntry != null) {
			assetEntryId = assetEntry.getEntryId();
			classPK = article.getPrimaryKey();
		}
	}
}
%>
....
<liferay-ui:input-asset-links assetEntryId="<%= assetEntryId %>" className="<%= JournalArticle.class.getName() %>" classPK="<%= classPK %>" />


Please note, that I copied only parts of the code, for deeper understanding you should read through the jsp file.
thumbnail
Tejas Kanani, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Thanks for the reply Vilmos.

Actually my requirement is to get Related Assets in my custom web content template. And over there I would not be able use any tag.
Do you think there is any other way by which I can achieve this ?

Thanks,
Tejas
thumbnail
Vilmos Papp, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 529 Beitrittsdatum: 21.10.10 Neueste Beiträge
Hi,

If you want to display them only, not adding more, I think you can access asset-links tag (it's accessible from $velocityTaglib variable).

Please note I haven't tried it, but If I'm right, it could work for you.
thumbnail
Tejas Kanani, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Hi Vilmos,

While I am searching for example on how to use $velocityTaglib I've found one post where its mentioned that
I'm pretty sure you can't add taglibs via web content template, By Bradley Wood
emoticon
http://www.liferay.com/community/forums/-/message_boards/message/22360843

If you can share any sample code which demonstrate the use of $velocityTaglib in web content template ? That would be really helpful.

Thanks,
Tejas
thumbnail
Vilmos Papp, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 529 Beitrittsdatum: 21.10.10 Neueste Beiträge
Hm,

In that case, I have no further idea. I checked and it seems you really can't do that from WCM Templates.
thumbnail
Tejas Kanani, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
emoticon Ok.
I'll have to find some alternate way then.
thumbnail
Vilmos Papp, geändert vor 10 Jahren.

RE: How to get Related Assets of web content in custom web content template

Liferay Master Beiträge: 529 Beitrittsdatum: 21.10.10 Neueste Beiträge
I hope you will have success with it. If so, please add your solution to this thread so others could reuse it.
thumbnail
Sriram Rajamani, geändert vor 8 Jahren.

RE: How to get Related Assets of web content in custom web content template

New Member Beitrag: 1 Beitrittsdatum: 06.05.15 Neueste Beiträge
I know this is an old thread. Is there any solution to it?
Lee Jordan, geändert vor 3 Jahren.

RE: How to get Related Assets of web content in custom web content template

Expert Beiträge: 449 Beitrittsdatum: 26.05.15 Neueste Beiträge
Has anyone found out how to add related assets to a template? I'm drawing a blank. In context what I need is something farily simple. The full content ADT for asset publisher shows related assets. I need that code from JSP in a Freemarker format.

Literally hopeless task, been on it for a week, no luck.

In 7.0 the JSP code doing it is, but no such luck trying to convert this to FTL

<liferay-asset:asset-links     assetEntryId="<%= assetEntry.getEntryId() %>"  portletURL="<%= assetLingsURL %>"  viewInContext="<%= assetPublisherDisplayContext.isAssetLinkBehaviorViewInPortlet() %>" />