Adding a Template to Display an Event

You should have a web content template for each new type of structure you add, as they define how to order and arrange each field in the structure.

Here, you’ll use HTML and FreeMarker tags to format the fields for an Event article.

Start Creating the Template

  1. Log in as Preston Palmer, your public site administrator (if you haven’t already).

  2. Navigate to the Site Menu (Site Menu) → Content & DataWeb Content.

  3. Click the Structures tab to get to the structures you created previously.

  4. Select Manage Templates in the Event structure’s Actions menu (Actions icon).

    Click Manage Templates to specifically add templates for this web content structure.

  5. Click Add (Add icon) to create a new template.

    The new template is associated automatically with the Event structure because you chose to manage templates for it.

  6. At the top of the page, enter Simple Event Format as the title.

  7. In the Properties menu (on the right side of the screen), enter this into the Description field: A generic template to display an event.

Configure the Template’s Fields

Now, arrange the order and format to display field data for Event articles.

  1. Click Elements (Elements icon) to reopen the Elements menu.

  2. Click into the body of the template and delete the placeholder text.

  3. In the Elements menu, scroll down to the fields under Journal and click Title.

    This automatically adds code that uses the title value.

    Clicking one of the fields in the Elements menu automatically fills in code to reference the field's contents (if they exist).

  4. Surround the code with H1 heading HTML tags (<h1>), like this:

    <h1>${.vars["reserved-article-title"].data}</h1>
    

    Event articles published with this template start with the title as an H1 header.

  5. In the Elements menu, scroll up to Fields and click Summary.

    This adds a reference to the Summary contents, as long as it exists. It uses the FreeMarker <#if> tag to do this.

  6. Surround the Summary text reference with H3 heading HTML tags (<h3>).

    HTML and FreeMarker tags are used together to format web content templates.

  7. Press Enter twice to add two new lines and, from the list of fields in the Elements menu, click Banner Image.

  8. Press Enter twice to add two more new lines, and add a separator line with an HTML tag (<hr>).

  9. Press Enter twice to add two more new lines and, from the list of fields in the Elements menu, click Body.

The completed Event template displays the title, the summary, the banner image, and then the article body beneath a separator line.

Now your Event template is complete, and you can display an Event article with a presentable format. You’ll see this later when you display an article on a page.

Next: create a template for the other structure you created, FAQs.

Relevant Concepts

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy