Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Maximiliano Chiesa
Get AssetEntry view URL
August 9, 2012 10:47 AM
Answer

Maximiliano Chiesa

Rank: Junior Member

Posts: 47

Join Date: July 20, 2012

Recent Posts

Hi!

I have a portlet in which I order assets according to their categories. For each AssetEntry I want to generate a link to it's "view". The problem is that I don't know how to get that URL programatically and set it to the link's href property.

Is there a way of making this?

Thanks in advance!
Dave Weitzel
RE: Get AssetEntry view URL
August 9, 2012 11:04 AM
Answer

Dave Weitzel

Rank: Regular Member

Posts: 186

Join Date: November 18, 2009

Recent Posts

I suggest you look at how AssetPublisher does it.
Basically it has to identify a page layout (plid) that contains the right portlet for the asset type you are displaying , then standard portlet options will allow you to maximize the portlet to show larger view of the asset.
G. B.
RE: Get AssetEntry view URL
October 29, 2012 5:31 AM
Answer

G. B.

Rank: New Member

Posts: 1

Join Date: October 22, 2012

Recent Posts

Hi!

In case you want to see the URL in each Asset Entry you can make a Hook for that. Just overwrite /WEB-INF/jsps/html/portlet/asset_publisher/display/full_content.jsp

and add the following content after line 217:

 1        <div class="urlBox">
 2                <hr/>
 3                <input id="entryButton" type="button" name="entryURL" value="Entry URL" onClick="toggle(this)" />
 4
 5                <div id="entryURL">
 6                        <%
 7                                String currentGroup = themeDisplay.getLayout().getGroup().getFriendlyURL();
 8                                String friendlyURL = themeDisplay.getPortalURL() + currentGroup + "/-/" + assetRenderer.getUrlTitle();
 9                        %>
10                        <a href="<%= friendlyURL %>"> <%= friendlyURL %> </a>
11                </div>
12        </div>
13
14        <script>
15                var entryURL = document.getElementById('entryURL');
16                var isShown = true;
17                entryURL.style.display = 'none';
18
19                function toggle(entryButton) {
20                        if (isShown)
21                        {
22                        entryURL.style.display = 'block';
23                                isShown = false;
24                                entryButton.value= 'Hide';
25                        }
26
27                        else
28                    {
29                entryURL.style.display = 'none';
30                                isShown = true;
31                                entryButton.value= 'Entry URL';
32                        }
33                 }
34        </script>


Now every AssetEntry has a Button in the bottom, which shows the friendly url.