In this chapter we will explore the relationship between a Page Template and a Page. We will build out an un-styled Magazine Article template based on some mockups from AdobeXD. In the process of building out the template, Core Components and advanced policy configurations are covered.
In this part of the tutorial, you will build a new Magazine Article Page template that can be used to create new magazine articles and aligns with a common structure. The template is based on designs and a UI Kit produced in AdobeXD. This chapter is only focused on building out the structure or skeleton of the template. No styles are implemented but the template and pages are functional.
When creating a page you must select a template, which is used as the basis for creating the new page. The template defines the structure of the resultant page, initial content, and allowed components.
Next, create a new template in AEM that matches the structure of the mockups. This will occur in a local instance of AEM. Follow the steps in the video below:
Pages in AEM are based off of a template. The basic site template created several templates for us and the sample content is based off of them. So, let’s go ahead and review these templates now.
I’ll navigate to tools general templates.
Under the weekend sites folder, we can see that we’ve got several page templates that have been already created, the article page, content page, page with right rail and homepage are all pages expected to be used on the site. The web variation is a special template just for experience fragments, which we’ll cover in the next video. Now, if we go ahead and open up the article page template we can see the basic structure.
We’ve got a global header and a global footer. We’ve got a title plate, a component placeholder and then a main container. The container defines which components are allowed to be added to the page.
Let’s go ahead and create a new template for our article page. I’ll return to the console and create a new template. I’ll select the page as the template type.
For the template title, I’ll put in magazine article page and then I’ll go ahead and click create.
Next, we can open up our new template.
When we open up our new template in structure mode we have a pre-defined container with several allowed components already configured. Next let’s add a header. A header is typically made up of multiple components and a standard best practice is to manage the header as an experience fragment. So, I’ll start by adding a new experience fragment component above the main container.
Next, I’ll configure the experience fragment to point to the header created by our site template. So, we can navigate through the structure and we can find the header variation. So, we’ll select that and click done. I’ll configure the policy of the experience fragment. Policies are similar to dialogues in that they allow us to configure various properties and behavior of a component. Policies differ in that they can be reused across templates to promote consistency.
Next, I’ll select the page header policy which is already defined by the site template. And the important thing here to realize is that we’re setting the CSS class two header, and then in our front end code, we can target this CSS class. You’ll also notice that the same policy is being used on the article page and the homepage and the content page with right rail. And so, this allows us to have consistency across our templates and ultimately across all of our pages.
And so, you’ll notice that once we save the changes that this header is now styled. And so, it’s picking up CSS rules based on this additional class.
I’ll repeat the same steps to include the footer. I’ll add another experience fragment component and I’ll configure it to point to the footer variation.
So now we’re pointing to the footer variation and you can see now the footer is populated. And again, I’m going to update the policy for this experience fragment. And this time I will select the policy of page footer. And again, you’ll notice we’ve got a footer CSS class that will get applied.
And once we saved those changes now you can see the styled footer.
Next, let’s start populating the main body of our template. So, the first thing that we’re going to do is actually lock this main container cause we’re going to introduce a two column layout. And so, in this main container I’m going to go ahead and update its policy.
So right now, the current policy is page content. And what I’m going to actually go ahead and do is introduce a new policy and we’ll call this body main. And this is going to define the main region of our page template. Now, one of the policies we can configure for containers is the allowed components. So, you’ll notice that we’ve got all of the core content components checked, as well as the core form components and the core structure components.
So, we’ll leave those settings set as default. And this time we’re also going to go ahead and update the styles and I’m going to introduce a default CSS class here. We’re going to call it main and we’ll target this with some CSS rules in the next chapter. And then we’re going to go ahead and clean up any of these additional styles.
So go ahead and click done to save our changes. I’ll go ahead and add an image component. We want this image component to be a fixed part of the template, but we want to give authors the ability to choose unique images per page. By unlocking the component, we can achieve this behavior. Users will not be able to remove this image from their page but they will be able to edit it.
Let’s add our breadcrumb component. The breadcrumb will not be edited at the page level but we will update the policy to configure where the breadcrumb navigation will start. I’ll go ahead and update the policy for the breadcrumb and I’ll select content breadcrumb and you’ll notice this is used on some of the other templates and this provides a standard CSS that we’ll target. Next, let’s go ahead and add our main content container.
So, I’ll insert a new component and we’re going to go ahead and add a new container component. And this time, since this will be editable I’ll unlock the component, and you’ll notice that it says no allowed components for the container. So, to update this, we’ll go into its policy.
And this time we’ll select the page content policy.
Now under allowed components, we want to be very specific which components authors can use. So here I’m going to actually uncheck the core structure components. Since this includes navigation we don’t think content authors will use those. The other thing we’ll review is the default components. So, whenever a user drags an image from the asset finder it’ll automatically use the image core content component.
We’ll leave the default styles as is and save the changes. So, notice now we have our allowed components that are populated.
Now in our mock-ups, we had a two-column layout. So, I’m going to introduce another container component that will act as the side rail.
I’ll go ahead and update this components policy. And since this is a new container that we really haven’t used before, I’ll introduce a new policy, we’ll call it magazine page side rail. Now this rail is going to be small, so we want to be very specific with which components we allowed. So, I’ll go ahead and add a button component, download image list separator social media sharing, text and title. So, these are the only components that will be allowed.
We’ll go ahead and click done.
And none of them are showing up right now. And so, what I need to do is actually unlock this component and now content authors will be able to use it.
So hopefully you are starting to see the power of the container component and how we can set these very granular policies to enforce what components are available and where they can be used. Now, if you recall in our layout we had our two columns sitting side by side. So next we’re going to engage something called lamp mode and actually shrink our main layout container so that it is eight columns wide.
And for our side rail, we’re again going to engage layout mode. And this time I’ll shrink it to four column slide dragging from right to left.
So, you’ll notice now the two containers are sitting side by side and then I’m actually going to create a one column gap in between the main container and the side container.
We can also update the policies for individual content components to enable more advanced authoring features.
Let’s go ahead and update the policy for our text component inside the main content container. So, I’ll click the policy icon, and this will bring up the policy dialogue for the text component.
So, I’ll go ahead and reuse an existing policy. And under plugins, you can see all these different features for the rich text editor. So go ahead and click through and enable some of these. So, we can add pasting, copying and pasting, find and replace go into formatting add a few additional formatting options. We’ll add underline and you can also enable different paragraph styles. So, for now, we’ll just leave it at paragraph block quote, and pre-formatted and then we’ll click done to save these changes. And so, these advanced editorial capabilities of the text component will be enabled whenever a text component is added to this main content container. At this point, the structure of the template looks good. Next, I’m going to switch into the initial content mode. Here, we can define several components that will be initially added to the page when it’s created. This will save content authors a little bit of time but they’ll also have the flexibility to remove or edit these components if needed.
I’ll start by adding a title component that will represent the main title for the article.
I’ll leave the default settings. Next, I’ll add a second title component and this will be kind of the by author line. So go ahead and pre-configure this, and we’ll enter the text by author, and this time I’ll set the size to H four.
And then I’ll go ahead and add one more text component to that main body.
All right, so that looks pretty good. Let’s go ahead and populate the side rail. I’ll go ahead and insert a new component and you’ll notice that the allowed components is far fewer than in the main container. And this is due to that policy configuration we created a few minutes earlier. I’ll go ahead and add a title component.
And so go ahead and populate this title component with shared this story. And this would just be a call to action to share this story on social media. We’ll set the size to H five.
Next, I’ll go ahead and add a component beneath that. And this will be our social media sharing component. We’ll leave those configurations as default. Beneath that, we’re going to go ahead and add a download component and this will allow a user to download a PDF version of the article. Beneath that we’ll add a list component and this will share a list of related articles.
Next, I’ll go ahead and set some initial page properties. Page properties are set of metadata that’s associated with the page. And what we can do at the template level is set up some initial page properties. So, we’re going to check social media sharing for Facebook and Pinterest.
Then we’ll save these changes.
And you’ll notice now the social media sharing icon is correctly populated. All right, so we’re finished with our changes. Let’s view the template in the admin console. So, I’ll click view in admin and you’ll notice that our template is currently in a draft state. So, content others aren’t able to use it. I’ll go ahead and enable it. Now that we’re ready to create pages from it. Let’s go ahead and add an icon so that we can easily identify our template.
I’ll go ahead and click properties for our template. And this is the properties for our magazine article page. And then I’ll go ahead and click upload image to upload a thumbnail for my file system. Then I’ll go ahead and save those changes. Next, you might have to hit refresh a couple of times to see the thumbnail appear, but there it goes. All right. So those are all the updates to the magazine article page template. In the next video, we will look to update the header and footer to match our mock-ups and the weekend design. - -
You can use the following thumbnail to identify your template (or upload your own!)