To better understand templates, now you’ll create a structure and an associated template. First create the structure:
-
Go to Content → Web Content from Site Administration page and open the Structures tab.
-
Click the Add button (
).
-
Name the structure News Article and add the following fields:
Field Type Field Label Name Text Title title
Text Box Abstract abstract
Image Image image
HTML Body body
-
Click Save.
Now create the template and connect it to the structure.
-
From the Web Content page, go to the Templates tab.
-
Click the Add button (
).
-
Enter the name News Article.
-
Open Details and make sure FreeMarker is selected as the script language (it’s the default).
-
Click Select under Structure.
-
Choose the News Article structure.
-
In the Script area, find the Fields label on the left and click on Title, Abstract, Image and Body into the editor area. It should look like this:
${title.getData()} ${abstract.getData()} <#if image.getData()?? && image.getData() != ""> <img alt="${image.getAttribute("alt")}" data-fileentryid="${image.getAttribute("fileEntryId")}" src="${image.getData()}" /> </#if> ${body.getData()}
-
Next, add heading and
<p>
tags and align the image to center to style your elements like this:<h1>${title.getData()}</h1> <p>${abstract.getData()}</p> <#if image.getData()?? && image.getData() != ""> <img alt="${image.getAttribute("alt")}" data-fileentryid="${image.getAttribute("fileEntryId")}" src="${image.getData()}" align="center" /> </#if> <p>${body.getData()}</p>
-
Click Save.
To finish it up, add some content:
-
Go to the Web Content tab.
-
Click on the Add button (
) and select News Article.
-
Insert some content and publish!
Figure 1: The Lunar Resort News Article is shaping up!