Tuesday, 14 October 2014

Embedding Web Content in a Portlet

Step 1: Login to portal as administrator. Go to Control Panel--> Liferay --> Wb Content.
  Before we create a new Web Content(article)  for the front page of our portlet, we have to do an important thing.  open "portal-setup-wizard.properties" under PORTAL_HOME

       append this code

     journal.article.force.autogenerate.id=false
     journal.structure.force.autogenerate.id=false
     journal.template.force.autogenerate.id=false

Save and restart the server

Now check the "Web Content" page click on  Add-->Basic Web Content  to create a new article
 now the  form will have a field to manually enter  the article id .this was not the case before.

Step 2: Create a new content with an ID as "WELCOME_MESSAGE"(you can give any meaningful name ), a title and some  contents. and  click on Publish .

Step 3:  In this step we are actually going to consume this Web Content(article) inside our portlet.
Open view.jsp and insert the tag immediately after the import and include statements.

<liferay-ui:journal-article articleId="WELCOME_MESSAGE"
     groupId="<%=themeDisplay.getScopeGroupId()%>">
     </liferay-ui:journal-article>
 
Save and check the front page of our portlet now.

No comments: