Wednesday 19 October 2016

Show webcontent based on artical Id

<%
               
                String articleName = PropsUtil.get("acticle.name");
       
                ThemeDisplay themeDisplay2 = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
                long groupId = themeDisplay.getScopeGroupId();
               
                JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle (themeDisplay.getScopeGroupId(), articleName);
                String articleId = journalArticle.getArticleId();       
               
               
%>
  <liferay-ui:journal-article articleId="<%=articleId %>" groupId="<%=groupId %>">
</liferay-ui:journal-article>


Depends on site...

<%
    PortletPreferences preferences = renderRequest.getPreferences();
    long groupId = GroupLocalServiceUtil.getFriendlyURLGroup(themeDisplay.getCompanyId(), "/ww").getGroupId();
%>

<c:if test="${programDetails.termsAndConditionsArticleId ne 0}">
    <liferay-ui:journal-article articleId="${programDetails.termsAndConditionsArticleId}" groupId="<%=groupId %>" />
</c:if>