Message Boards
How to get Related Assets of web content in custom web content template ?
Tejas Kanani, modified 10 Years ago.
How to get Related Assets of web content in custom web content template ?
Liferay Master Posts: 654 Join Date: 1/6/09 Recent Posts
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
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
Vilmos Papp, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 529 Join Date: 10/21/10 Recent Posts
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):
Please note, that I copied only parts of the code, for deeper understanding you should read through the jsp file.
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.
Tejas Kanani, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 654 Join Date: 1/6/09 Recent Posts
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
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
Vilmos Papp, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 529 Join Date: 10/21/10 Recent Posts
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.
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.
Tejas Kanani, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 654 Join Date: 1/6/09 Recent Posts
Hi Vilmos,
While I am searching for example on how to use $velocityTaglib I've found one post where its mentioned that
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
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
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
Vilmos Papp, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 529 Join Date: 10/21/10 Recent Posts
Hm,
In that case, I have no further idea. I checked and it seems you really can't do that from WCM Templates.
In that case, I have no further idea. I checked and it seems you really can't do that from WCM Templates.
Tejas Kanani, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 654 Join Date: 1/6/09 Recent Posts
Ok.
I'll have to find some alternate way then.
I'll have to find some alternate way then.
Vilmos Papp, modified 10 Years ago.
RE: How to get Related Assets of web content in custom web content template
Liferay Master Posts: 529 Join Date: 10/21/10 Recent Posts
I hope you will have success with it. If so, please add your solution to this thread so others could reuse it.
Sriram Rajamani, modified 8 Years ago.
RE: How to get Related Assets of web content in custom web content template
New Member Post: 1 Join Date: 5/6/15 Recent Posts
I know this is an old thread. Is there any solution to it?
Lee Jordan, modified 3 Years ago.
RE: How to get Related Assets of web content in custom web content template
Expert Posts: 449 Join Date: 5/26/15 Recent Posts
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
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() %>" />