Remove version number from assets links in Liferay 7.2 GA1

Elena Stefanova, modified 6 Years ago. Junior Member Posts: 42 Join Date: 8/24/15 Recent Posts
Hi, there!

I'm using the Asset publisher portlet to display a list of assets inside some pages of my projects as in Display configurations of the portlet I set the option to "View in Context" these assets. However, I noticed that there is some number (probably a version number or something else) displayed as a query parameter in the asset full view URL. In the older liferay versions this number was not set, but in liferay 7.2-ga1 yes. Is there any possibility to remove this number from the assets URL?

Thanks in advance,
Eli
thumbnail
Mohammed yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi,
Can you please share which part in the url your are referring.
Elena Stefanova, modified 6 Years ago. Junior Member Posts: 42 Join Date: 8/24/15 Recent Posts
Hi, Mohammed!

Yes, this is a version number added right after the asset friendly url. It looks like that: domainname.com/-/<asset_friendly_url>/<version_number>?redirect=%2F<render_page>
thumbnail
Mohammed Yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
I think that is portlet instance id which you are referring as version number
Elena Stefanova, modified 6 Years ago. Junior Member Posts: 42 Join Date: 8/24/15 Recent Posts
No, I checked and this is the article version actually. It is a number like 1.2, 1.3...2.0 and increments each time I republish the article. By some strange reason this version in the URL causes me problems with the asset full preview. I get a syntax error in the template of type:
"Syntax error in template "companyId#companyGroupId#null" in line 4, column 67: Encountered ".", but was expecting:">""
which is actually some parser error. And more strange is that this error is gone once I remove the article version from the rendered url.
thumbnail
Mohammed Yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
can you share your template code snippet may be i can try and fix the error
Elena Stefanova, modified 6 Years ago. Junior Member Posts: 42 Join Date: 8/24/15 Recent Posts
In the Asset publisher ADT I use the standard code to link the assets:

<#assign assetRenderer = curEntry.getAssetRenderer() />
<#assign curEntryTitle = htmlUtil.escape(assetRenderer.getTitle(locale)) />
<#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, assetRenderer, curEntry, !stringUtil.equals(assetLinkBehavior, "showFullContent")) />

<h3 class="asset-title"><a href="${viewURL}">${entryTitle}</a></h3>

where stringUtil.equals(assetLinkBehavior, "showFullContent") == false

Then the full_view template code is a standard code that retrieves and show data from all the attributes of the journal article. And here, I should mention that the structure that I created for these assets is a little bit complex. By complex I mean that it has nested and repeatable attributes. I assume that the internal parser might have some difficulties with these attributes, but this is only an assumption.
Elena Stefanova, modified 6 Years ago. Junior Member Posts: 42 Join Date: 8/24/15 Recent Posts
Hi, Mohammed!

I found a workarround to solve my problem. Finally, I used the following code for assets full-view links:
&lt;#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, curEntry) /&gt;
&lt;#if assetLinkBehavior != "showFullContent"&gt;
      &lt;#assign viewURL = assetRenderer.getURLViewInContext(renderRequest, renderResponse, viewURL)?keep_before_last('/') + '?redirect=' + htmlUtil.escapeURL( themeDisplay.getURLCurrent() ) /&gt;
<!--#if-->
<h3 class="asset-title"><a href="${viewURL}">${entryTitle}</a></h3>
​​​​​​​This is how I manage to remove the version number from the url and like that assets full view is rendered correctly.

Thank you for trying to help me!

Greetings,
Eli