Tuesday, August 25, 2015

Structure and Templates for Web Content in Liferay

Today we will discuss about Structure and Templates for Web Content in Liferay . Lets consider a scenario where we have to create 100 web contents for Mobiles which are almost similar except the names, camera ie small differences. So 100 times you have to write the similar HTML. What if you just create a Template one time and use it again and again.This is the main task of structure and Templates in Liferay.

Here we create a Structure and Template that provide user some Text fields and user just enter the values in those fields and web content create automatically. Before reading this blog it is highly recommended to read my previous blog on Basic web content in liferay

So lets start step by step:-

Step 1:-Create Structure for Web Content
Go to Admin->Content->Web Content->Manage->Structure

Then a new window is open Click on Add. After that fill name and details :-

After that create 4 text fields Brand,Model Number,Description , price and one select box Camera using GUI provided by Liferay . By clicking setting tab you can change the label and required properties of the fields

Then Click save.

Step 2:-Create Template for Structure
In this Step we create Template for the structure that is created in Step 1 ie Mobile_Structure . In Template we create static HTML and provide the dynamic fields to it.

Go to Admin->Content->Web Content->Manage->Templates

Provide Name and Select Structure as Mobile_Structure which is created in Step 1. From language select box select Velocity.

After that you can use your fields in HTML as :-

Now Click Save.

Step 3:-Create Web Content
Go to Admin->Content->Web Content->Add->Mobile_Structure

As soon as you select Mobile_Structure .The Structure and Template are already selected here fill the other values like brand , description etc.

Now Click Publish.

Step 4:-Check Output
Now add web Content Display Portlet to your page and select your web content and see the output.

Step 5:-Database Tables

This table contain the structure in xml format in xsd column

This table save template in script column in Text format

Now this table contain the ids of both 

Note:- I hide the other fields in tables SnapShots.

That's it ,Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!