Web contents are the great feature, which is very useful to create contents easily on our liferay portal. By using web content structure and templates, we can make our web content creation process a lot easier and simple. This will be helpful when certain content is created for multiple times, with same type of content architecture. In this post, we will see how to create a web content structure and a web content template to put that structure together.

Following are the main steps:

  • Create a web content structure.
  • Create a web content template to put the structure fields together.
  • Create a web content using above created structure.

Create a web content structure

To create a web content structure, login with admin credentials, navigate to Admin > Content > Web Content > Manage > Structures and click on Add button. This will open up structure configuration window as shown below. Enter a structure name on Name field.

structure1

Now select the required field components from the available structure fields, as shown below. we have different fields available which can be included in our web content structure. In this example, we have selected a text field, an image field and a text box field as shown below. Click on Save button to save the created web content structure.

structure2

 

Create a web content template to put the structure fields together

Once the web content structure is created, we have to put all the structure fields together to make a meaningful content. This can be done with the help of a web content template. Liferay supports Freemarker(FTL), Velocity(VM) and Extensible Style Sheet Language (XSL) template languages.

To create a web content template, navigate to Manage > Templates and click on Add button. This will open up template configuration window as shown below. Enter the Name field, select the structure to be used and the template language.

template1

Add the fields by clicking on left side of the scripts field and click on Save button. Here,since we have not modified the field names, liferay has given with some random field names. We can add any styling and html components to make our content look rich on this script field.

<h2>${Text1767.getData()}</h2>
<img alt="Image" src="${Image2034.getData()}" />
${Text_Box2282.getData()}

 

Create a web content using above created structure

Finally create a web content and change the default structure with the one we have created. Associated template will be automatically selected. Fill in the fields, and click on save.

wc1

Finally our web content is ready with predefined template.

wc2

Also Read:

 

Note: Version used: Liferay 6.2