Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Tejas Kanani
How to get Related Assets of web content in custom web content template ?
1. Mai 2013 06:23
Antwort

Tejas Kanani

Rang: Liferay Master

Nachrichten: 653

Eintrittsdatum: 6. Januar 2009

Neue 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
Vilmos Papp
RE: How to get Related Assets of web content in custom web content template
1. Mai 2013 07:27
Antwort

Vilmos Papp

LIFERAY STAFF

Rang: Expert

Nachrichten: 473

Eintrittsdatum: 21. Oktober 2010

Neue 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):

 1
 2<%
 3JournalArticle article = (JournalArticle)request.getAttribute(WebKeys.JOURNAL_ARTICLE);
 4
 5long assetEntryId = 0;
 6long classPK = 0;
 7
 8if (article != null) {
 9    classPK = article.getResourcePrimKey();
10
11    if (!article.isApproved() && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT)) {
12        AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(JournalArticle.class.getName(), article.getPrimaryKey());
13
14        if (assetEntry != null) {
15            assetEntryId = assetEntry.getEntryId();
16            classPK = article.getPrimaryKey();
17        }
18    }
19}
20%>
21....
22<liferay-ui:input-asset-links
23        assetEntryId="<%= assetEntryId %>"
24        className="<%= JournalArticle.class.getName() %>"
25        classPK="<%= classPK %>"
26    />


Please note, that I copied only parts of the code, for deeper understanding you should read through the jsp file.
Tejas Kanani
RE: How to get Related Assets of web content in custom web content template
1. Mai 2013 09:06
Antwort

Tejas Kanani

Rang: Liferay Master

Nachrichten: 653

Eintrittsdatum: 6. Januar 2009

Neue 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
Vilmos Papp
RE: How to get Related Assets of web content in custom web content template
2. Mai 2013 01:36
Antwort

Vilmos Papp

LIFERAY STAFF

Rang: Expert

Nachrichten: 473

Eintrittsdatum: 21. Oktober 2010

Neue 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.
Tejas Kanani
RE: How to get Related Assets of web content in custom web content template
2. Mai 2013 02:11
Antwort

Tejas Kanani

Rang: Liferay Master

Nachrichten: 653

Eintrittsdatum: 6. Januar 2009

Neue 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
Vilmos Papp
RE: How to get Related Assets of web content in custom web content template
2. Mai 2013 02:37
Antwort

Vilmos Papp

LIFERAY STAFF

Rang: Expert

Nachrichten: 473

Eintrittsdatum: 21. Oktober 2010

Neue 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.
Tejas Kanani
RE: How to get Related Assets of web content in custom web content template
2. Mai 2013 02:39
Antwort

Tejas Kanani

Rang: Liferay Master

Nachrichten: 653

Eintrittsdatum: 6. Januar 2009

Neue Beiträge

emoticon Ok.
I'll have to find some alternate way then.
Vilmos Papp
RE: How to get Related Assets of web content in custom web content template
2. Mai 2013 03:59
Antwort

Vilmos Papp

LIFERAY STAFF

Rang: Expert

Nachrichten: 473

Eintrittsdatum: 21. Oktober 2010

Neue Beiträge

I hope you will have success with it. If so, please add your solution to this thread so others could reuse it.