Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

practical liferay Java -based Portal Applications development apress phần 9 ppsx
Nội dung xem thử
Mô tả chi tiết
270 Chapter 10 ■ PUBLISHING DYNAMIC CONTENT
This screen displays a list of existing templates at the bottom. This list is currently blank
because you haven’t yet defined any templates. We’ll remedy that now.
Adding a Template
To create a new template, follow the steps listed here:
1. Click the Add Template button. You will see the screen shown in Figure 10-12.
Figure 10-12. Creating a new template
2. Do the following things on the displayed screen:
a. Autogenerate ID: Mark this check box. The application will now autogenerate the ID
for the new template.
b. Name: Enter Announcement Template.
c. Description: Enter This is a page template for the announcement type of journal
article.
Chapter 10 ■ PUBLISHING DYNAMIC CONTENT 271
d. Cacheable: Leave this box checked (the default).
e. Structure: Click the appropriate button to select or remove the earlier selected
structures.
f. Language Type: You get three choices here:
i. VM: Velocity is a powerful Java-based template engine. It renders data from
plain Java objects to various formats.
ii. XSL: Extensible Stylesheet Language (XSL) is a language for expressing style
sheets. Like CSS, it contains information on how to render an XML document.
iii. CSS: Cascading Style Sheets (CSS) is a widely accepted standard for creating
style sheets to define how web-page information will be rendered.
g. Script: Specify the file that defines the template structure. Because you can create
the template structure in VM, XSL, or CSS, you should select the appropriate file
based on the language selection in the Language Type field. To locate the file on the
system, use the Browse button. Alternatively, you can create a new file on the fly
using the Launch Editor button.
nNote As mentioned earlier, a template defines the formatting instructions for each field defined in the
structure. When the user views the article, these formatting instructions will be applied to the various fields
defined in the structure and the formatted output will be rendered in the user’s browser. You can specify
such formatting instructions in VM, XSL, or CSS, but describing the formatting instructions is beyond the
scope of this book.
h. Format Script: Mark this check box if you want to format your script. You must save
the document by clicking the Save and Continue button or the Save button to see
the effects of this action. The opportunity to format the script is especially useful if
you created the script in an external editor and did not indent it properly.
i. Small Image URL: Specify the URL of the image to be used for identifying the
template.
j. Small Image: Alternatively, you can specify an image from the local disk. To locate
the image, use the Browse button.
k. Use Small Image: If you have populated the Small Image field, check this box.
l. Permissions: Use this section to set the various permissions for Regular and Community roles. For now, leave these at their default values.
3. Click the Save button to save your edits.
272 Chapter 10 ■ PUBLISHING DYNAMIC CONTENT
Viewing and Searching Templates
After you have created a template and saved it, it will appear in the list of templates on the
Templates screen in the main application view (see Figure 10-13).
Figure 10-13. View of predefined templates
As in the case of structures, the view screen has a search facility that lets you narrow down
the list of templates displayed. You can enter the search string in the Search edit box and click
the Search Templates button to locate the templates matching the search criterion.
Performing Actions on Templates
The actions you can perform on templates are similar to the actions you can perform on
structures:
• Edit: This allows you to edit the selected template. Selecting this action opens the template in the editor, giving you the opportunity to edit any of the fields.
• Permissions: This action allows you to set user permissions on the selected template for
the Regular and Community roles.
• Copy: This option allows you to make a copy of the selected template under a new ID.
• Add Article: This action allows you to add a new article based on the current template.
I’ll discuss adding articles in the section “Creating Journal Articles.”
• View Articles: This option displays all the existing articles based on the currently
selected template.