Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Journal Article View url generation from custom portlet in liferay 6.2
Hello,
Does anyone have any idea about how to generate journal article view url from custom portlet.
I have tried below code but it is not working.
<liferay-portlet:renderURL portletName="15" var="previewArticleContentURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/journal/preview_article_content" />
<portlet:param name="groupId" value="${i.groupId}" />
<portlet:param name="articleId" value="${i.articleId}" />
<portlet:param name="version" value="${i.version}" />
</liferay-portlet:renderURL>
<a href="${previewArticleContentURL}">Content</a>
Thanks,
Vishal Munjani
Hello,
I found solution. Added plid.
<%
long plid=0;
Layout layout = LayoutLocalServiceUtil.fetchFirstLayout(
themeDisplay.getScopeGroupId(), false,
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
if (layout == null) {
layout = LayoutLocalServiceUtil.fetchFirstLayout(
themeDisplay.getScopeGroupId(), true,
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
}
if (layout != null) {
plid= layout.getPlid();
}
%>
<liferay-portlet:renderURL plid="<%=plid%" var="previewArticleContentURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>" portletName="15">
<portlet:param name="struts_action" value="/journal/preview_article_content" />
<portlet:param name="groupId" value="<%= String.valueOf(article.getGroupId()) %>" />
<portlet:param name="articleId" value="<%= article.getArticleId() %>" />
<portlet:param name="version" value="<%= String.valueOf(article.getVersion()) %>" />
</liferay-portlet:renderURL>
<%
String taglibOnClick = "Liferay.fire('previewArticle', {title: '" + HtmlUtil.escapeJS(article.getTitle(locale)) + "', uri: '" + HtmlUtil.escapeJS(previewArticleContentURL.toString()) + "'});";
%>
<a href="javascript:void(0);" onclick="<%= taglibOnClick %>">
Click Here
</a>
Thanks,
Vishal Munjani