DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more

Creating an Article List With IBM WCM 8.0 (Part 2)

Continuing on with the series, in part two we'll be creating the WCM building blocks required to create and render a single article. Read on and see how it's done.

Roan Bester user avatar by
Roan Bester
·
Jun. 24, 16 · Tutorial
Like (1)
Save
Tweet
Share
3.17K Views

Join the DZone community and get the full member experience.

Join For Free

In Part 1, we discussed the requirements for following this series of articles, created the WCM libraries, and set up a simple workflow.

In Part 2, we continue by creating the WCM building blocks required to create and render a single article. More specifically we will be:

  1. Creating a site area where content items will be added.

  2. Creating an authoring template for an article.

  3. Creating a presentation template to render an article content item.

  4. Setting various defaults and values to make our lives easier in upcoming development.

Step 1: Create the Site Area

On the article-list-content library, go to “Content” and click the “New” button -> Site area -> Default site area template.

Set the name and display title to “Articles” and click “Save and Close”.

You should now have something like this:

Image title

Step 2: Create the Article Authoring Template

To create a content item in WCM, you need to have an Authoring template.

Note

The authoring template is a form you use to create content items with, while the presentation template renders the content item(s).

Under article-list-design, go to Authoring Templates, click on the ‘New’ button -> Content template.

Image title

Specify an appropriate name and display title.

Under the section ‘Location options’, specify that content items will be created under our content library’s Articles site area:

Location options

Don’t worry about the ‘Default Presentation Template’ for now, we will set this soon.

Now, add the custom elements for the authoring template. Click on ‘Manage Elements’ and add the following elements:

  • Title: Short Text element
  • Author (custom author): Short Text element. This author is the person that wrote the article and not the WCM author. In the future, we could add an ‘authors’ select box here.
  • Image: Captures our article image as an Image element.
  • Article lead: Text element; the Text element is an HTML ‘area’, while a short text element is an input. The article lead is the lead paragraph to show in the list view as well as the first paragraph on the article detail view.
  • Article body: Rich Text element, to allow a WCM author to provide html for the main body of the article.

The result should look like this:

Image title

Save and Close.

Note

It is good practice to hide elements on an authoring template that the WCM author does not need to use, or should not use. I also recommend providing help text for each element. It’s out of scope for this article on how to do this.

Step 3: Create the Presentation Template

The presentation template for an article will be used to render out an individual article on a page.

Under the article-list-design library, go to Presentation Templates and click New -> Presentation Template.

Provide the name and title.

Open up the plunker example and view the "articleDetail.html" file. Copy everything in the <article>...</article> straight into the presentation template.

Once this is done, replace all the mock text with WCM element tags from the Article authoring template:

  1. Highlight some mock text to replace with an element from the content item (via the authoring template elements);

  2. Click on "Insert Tag", then select the appropriate element:

    1. Tag type -> Element

    2. Source item type -> Content

    3. Item context -> Current

    4. Authoring template -> the article authoring template

    5. Element to reference -> choose the appropriate element from the authoring template

Inserting a tag

The end-result is an element tag looking like this (for the article title in this case):

[Element context="current" type="content" key="Title"]

Save and close.

To review your changes, you can have a look at "article_list_listing_1.html" from the gist.

Note on element tags

For the article image, we want to use the url and alt text only, as we want to use bootstrap’s styling classes. With WCM Element tags, you can request it to output a property of that element. For example, by default, an image Element outputs the img tag, but you can tell it to output the URL instead:

[Element context=”current” type=”content” key=”Image” format=”url”]

Have a look here for more information.

Note on generic content item properties

For our article, we want to render the published date. This is a built-in property of any content item. To do this, you need to use a Property tag (inserted in a similar way to Element tags).

If I want to, for example, render out the current content item’s published date where the date is shown as e.g. Jun 7, 2016:

[Property context=”current” type=”content” format=”DATE_MEDIUM” field=”publishdate”]

You can read more on this here.

Step 4: Set Template Default Content Item Properties

Now that we have an article authoring and presentation template, as well as workflow and a site area where our articles are created, we can set up defaults to assist the creation of content items and allow the article details page to display correctly.

Set the Presentation Template as Default

Edit the article authoring template and select the presentation template we created earlier as the Default Presentation Template (under Item Properties).

Save and Close.

This will now ensure that content items created with this authoring template use this presentation template by default.

Specify Child Template Mappings

We need to give the web content viewer (portlet) information on the kind of content items to be rendered, as the viewer will need to render content items based on an incoming link (more on this later) as opposed to a specific content item. To do this, you tell the site area to render its children based on a child template mapping.

Go to the article-list-content library and edit the Articles site area.

Under Child Template Mappings, click ‘Manage Template Maps’.

Click ‘Add’ and then browse for the Authoring Template and Presentation template we created.

Child template mappings

Click OK; you should now see it displayed in the Manage Template Maps view:

Manage template maps

Select it and click OK. You should now have a site area that looks like this:

Site area with child template mappings

Summary

This was quite a mouthful, but in Part II we created the building blocks for an individual article, namely an authoring and presentation template. We also set some defaults to assist us with content item creation and provided defaults for the Site Area storing our articles (as content items) so that the web content viewer portlet has something to work with.

In Part 3, we'll tackle the article list view which will render out all the articles listed under our site area.

Template Element

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Building the Next-Generation Data Lakehouse: 10X Performance
  • A Beginner's Guide to Infrastructure as Code
  • 5 Software Developer Competencies: How To Recognize a Good Programmer
  • Top 11 Git Commands That Every Developer Should Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: