Thursday, September 22, 2016

Embedding a Web Content/Journal Article in a Portlet


We already knew how to embed a portlet in web content but today we try to embed a web content in our custom portlet.Before reading this blog you must know how to Create a web content in liferay.
So lets start this step by step:-







Step 1:-Create a basic web content
Just create a basic web content like this:-



The title of my web content is EmbeddedInPortlet.






Step 2:-Embed in Portlet
Now create a portlet and paste this content in view.jsp:-

<%@page import="com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"%>
<%@page import="com.liferay.portlet.journal.model.JournalArticle"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="theme" %>
<theme:defineObjects/>
<%
JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle (themeDisplay.getScopeGroupId(), "EmbeddedInPortlet");
String articleId = journalArticle.getArticleId();
long groupId = themeDisplay.getScopeGroupId();
%>
<div><liferay-ui:journal-article articleId="<%=articleId%>" groupId="<%= groupId %>"/></div>
view raw view.jsp hosted with ❤ by GitHub


That's it Now deploy the portlet and check the output as:-



Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

1042945

Number Of Unique Visitor

Free counters!