Creating A Site
Step 4 of 6
As you’ve now seen, creating pages can be repetitive. Wouldn’t it be great if you could create multiple pages from a single template? Well guess what: page templates in Liferay DXP let you do exactly that! They also inherit future changes to those pages.
Now you’ll use page templates in The Lunar Resort. First you’ll create a page template, then you’ll use it to create several pages. Later, you’ll make changes to the template and see Liferay DXP propagate those changes to the pages you created from the template.
Creating a Page Template
Use these steps to create a page template:
-
Open the Main Menu and select Control Panel → Sites → Page Templates. The Page Templates page lists all the page templates in the Liferay DXP instance. Three page templates come bundled with Liferay DXP. Blog and Wiki are example layouts for the Blogs and Wiki applications. Content Display Page serves a special function that you’ll work with later.
Figure 1: The Page Templates page.
-
Click the Add button (
) in the lower right corner. This takes you to the page template creation page.
-
Name the template Lunar Guide Page.
-
For the description, enter Page with information about a Lunar Guide.
-
Click Save. This takes you back to the list of page templates, where you can see the new template in the list.
Editing a Page Template
Editing a page template is similar to editing any page. You drag and drop applications onto the page and reposition or remove them as desired. The only difference is that you can’t directly add content, and some configuration and display options are disabled (it’s a template, after all). Follow these steps to edit the page template you just created:
-
In the list of page templates, click Lunar Guide Page. This opens it in a new browser tab or window.
Figure 2: Click the page template to edit it.
-
In the page template’s edit toolbar click the Add button (
) on the upper right and expand the Applications → Collaboration category. Add a Blogs portlet to the page template’s right column.
-
Close the page template’s edit tab/window. Liferay DXP automatically saves your changes.
Next, you’ll create a page with this template.
Creating a Page with a Page Template
Follow these steps to use the template to create a page:
-
Open the Main Menu and select The Lunar Resort → Navigation.
-
In the Navigation menu, click the Options button (
) for Public Pages and select Add Public Page.
-
Name the page Cody (Cody is one of our lunar guides).
-
Under Type, select Lunar Guide Page. This selects your page template as the source for the page.
-
Leave Inherit Changes set to Yes. This lets you edit this page in the future by editing the template, but removes the ability to edit the page directly.
-
Click Add Page.
Liferay DXP then creates the new page from your template. Next, you’ll create more of these pages, one for each lunar guide (Cody is awesome, but he can’t do everything by himself). Note, however, that Cody’s page is in the navigation bar next to all the other pages. To get his page and those of the other lunar guides under the Lunar Guides page, you must nest the pages. You’ll learn how to do this next.