Content Item Templates
Here is the temp-dev
publication's
article/markup/news.jsp
template:
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <h2> ${article.fields.title} </h2> <div class="date"> <fmt:formatDate value="${article.lastModifiedDateAsDate}"/> </div> <div class="byline"> Written by ${article.author.name} </div> <div class="summary"> ${article.fields.summary} </div> <div class="body"> ${article.fields.body} <c:forEach items="${article.relatedElements.images.items}" var="related"> <img src="${related.content.fields.alternates.value.SmallSquare.href}" alt="${related.fields.caption}" width="${article.fields.alternates.value.SmallSquare.width}" height="${article.fields.alternates.value.SmallSquare.height}"/> </c:forEach> </div> <div class="stories"> <h3>Related articles</h3> <ul> <c:forEach items="${article.relatedElements.stories.items}" var="related"> <li> <a href="${related.content.url}">${related.fields.title}</a> </li> </c:forEach> </ul> </div>
This file contains the HTML needed to present the content item,
and uses JSP expressions to retrieve the desired fields from the
article
bean at the appropriate points in the
document. Note in particular:
-
The
article
bean'sauthor
property is aPresentationPerson
bean, which in turn has aname
property that holds the author's name. This property can be directly accessed using the expression language, as shown in the "byline"div
above. -
The "body"
div
contains thebody
field, followed by a JSTLforEach
element that displays all the content item's relatedimages
(images
is the name of arelation-type
defined in thecontent-type
resource). Thearticle
bean'sarticles
property is an array ofPresentationRelationArticle
elements. -
Similarly, the "stories"
div
contains a JSTLforEach
element that is used to output an HTML link to all the content item's relatedstories
(stories
is the name of arelation-type
defined in thecontent-type
resource).