您可以将任何元数据包含到 Jahia 为您的页面生成的 head html 中。这是我们页面之一的 html 输出示例:
<meta name="dcterms.created" content="Mon May 26 08:06:56 CEST 2018" />
<meta name="dcterms.modified" content="Tue Oct 30 10:40:43 CET 2018" />
<meta name="dcterms.issued " content="Wed Oct 31 09:09:53 CET 2018" />
为了检索它们,您需要使用当前页面节点:
<c:set var="pageNode" value="${jcr:getParentOfType(currentNode, 'jnt:page')}"/>
<c:if test="${empty pageNode}">
<c:choose>
<c:when test="${jcr:isNodeType(renderContext.mainResource.node, 'jnt:page')}">
<c:set var="pageNode" value="${renderContext.mainResource.node}"/>
</c:when>
<c:otherwise>
<c:set var="pageNode" value="${jcr:getParentOfType(renderContext.mainResource.node, 'jnt:page')}"/>
</c:otherwise>
</c:choose>
</c:if>
根据 Jahia API,您可以检索以下页面属性:
<c:set var="dateOfCreation" value="${pageNode.creationDateAsDate}" />
<c:set var="dateOfLastModification" value="${pageNode.lastModifiedAsDate}" />
<c:set var="dateOfLastPublication" value="${pageNode.lastPublishedAsDate}" />
然后将它们输出到您的组件视图或模板中:
<c:if test="${!empty dateOfCreation}"><meta name="dcterms.created" content="${fn:escapeXml(dateOfCreation)}" /></c:if>
<c:if test="${!empty dateOfLastModification}"><meta name="dcterms.modified" content="${fn:escapeXml(dateOfLastModification)}" /></c:if>
<c:if test="${!empty dateOfLastPublication}"><meta name="dcterms.issued " content="${fn:escapeXml(dateOfLastPublication)}" /></c:if>