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:-
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@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> |
That's it Now deploy the portlet and check the output as:-
Hope this will Help....
Related Post:-
Carousel in Liferay using portlet
Structures and Templates in Web Content
Fetch Web Content Programatically
Get Journal Article Fields Using SAX Parser
Embedding a Portlet in Web Content
Creating tabs using Web Content
How to install Maven
Fetch Latest Version Journal Article or Web Content in Liferay
No comments:
Post a Comment