#3 Building the Base Page

Presented by David G.

Create a base page that is used as the foundation for all other project Page implementations.

Page Component Defintion

Inherits from foundation/components/page to inherit OOTB Page features from AEM.

/apps/aemcasts/demo/components/page/basepage/.content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
	xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
	jcr:primaryType="cq:Component"
	jcr:title="AEM Casts Demo Base Page"
	componentGroup=".hidden"
	sling:resourceSuperType="foundation/components/page"
	/>

Page Component Defintion

Overlay of the AEM foundation Page component’s head.jsp.

/apps/aemcasts/demo/components/content/page/basepage/head.jsp

<%@include file="/apps/aemcasts/demo/global/global.jsp"%><%
%><%@page session="false" import="com.adobe.granite.xss.XSSAPI"%><%

    /* Services */
    final XSSAPI xss = sling.getService(XSSAPI.class);

    /* Page Properties */
    final String pageTitle = currentPage.getPageTitle();
    final String pageDescription = currentPage.getDescription();
%>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><%= xss.encodeForHTML(pageTitle) %></title>
    <meta name="description" content="<%= xss.encodeForHTML(pageDescription) %>">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <cq:include script="headlibs.jsp"/>
    <cq:include script="/libs/wcm/core/components/init/init.jsp"/>
</head>

Contains the embeds for all the ClientLibs used across the pages using this Base Page.

/apps/aemcasts/demo/components/content/page/basepage/headlibs.jsp

<%@include file="/apps/aemcasts/demo/global/global.jsp"%><%
%><%@page session="false"%><%
%><cq:includeClientLib categories="cq.foundation-main"/><%
%><cq:include script="/libs/cq/cloudserviceconfigs/components/servicelibs/servicelibs.jsp"/><%
    currentDesign.writeCssIncludes(pageContext); %>

<cq:includeClientLib css="aemcasts.demo.all"/>

Page Component Definition

Overlay of the AEM foundation Page component’s body.jsp and defines the shared structure of the Site.

/apps/aemcasts/demo/components/content/page/basepage/body.jsp

<%@include file="/apps/aemcasts/demo/global/global.jsp"%><%
%><%@page session="false"%><%
%><body>
    <div class="container_12">
        <header class="header clearfix">
            <div class="grid_4 logo">AEM Casts</div>
            <div class="grid_8 nav">
                <ul>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">Page 1</a></li>
                    <li><a href="#">Page 2</a></li>
                </ul>
            </div>
        </header>

        <hr/>

        <div class="page-content">
           <cq:include script="main.jsp"/>
        </div>

        <hr/>

        <footer class="footer clearfix">
            2013 AEM Casts
        </footer>

    </div>

    <cq:includeClientLib js="aemcasts.demo.all"/>
</body>

CSS and JavaScript

CSS and JavaScript used across the site is added to the site’s “main” ClientLib.

/etc/clientlibs/aemcasts/demo/main/*