Putting It All Together
Now that you have a general idea of how
publishing content types, master pages, and page layouts work. I will
demonstrate how they all work together. For the sake of my
demonstration I shall use out-of-the-box content types, page layouts,
and master pages.
- Open the SharePoint publishing site (created earlier in this chapter).
- Click the gear icon.
- Select the menu item to view all site content.
- Click the Pages document library ellipses.
- Navigate to the Pages document library settings.
- Scroll to the section for content types.
Figure 8
shows the content types listed in my publishing site pages library,
which tells me I can create Welcome Pages, Article Pages, Error Pages,
and base Publishing Pages.
Note Error Pages are new to SharePoint 2013.
- Return to the Site contents page.
- Click the Pages document library to access the pages in the current site.
- You should see a page similar to that in Figure 9.
As you can see by looking at Figure 9,
the pages library is similar to any other document library, in that it
contains a file and associated metadata—page instances. Each page
instance is a list item with attached ASPX file. You might assume that
the attached ASPX file is the page layout, but it is not. If you
download the ASPX file and open the file in Notepad, the file contains
references to the page layout in the Master Page Gallery and other
publishing-related data.
- 10. Click the ellipses for the page instance.
- 11. From the settings popup ellipses, click the menu item to view properties.
- 12. Figure 10 shows a list of site columns and associated values.
The page shown in Figure 10
is the “list view” of a publishing page. Just like any other list or
document library, a content owner may edit the values (properties) for
each column of the list item. Next, I shall show you how the property
data renders on publishing pages, using a page layout.
- 13. Click the gear icon.
- 14. Select the menu item for creating a new page.
- 15. In the dialog that appears, give the page a name.
- 16. Click the OK button.
- 17. You should see a page like that in Figure 11.
What just happened? In response to you
requesting a new page, SharePoint created a new page instance in the
Pages document library, using the default content type for the library
and default page layout. You might be wondering how SharePoint decided
which content type and page layout it chose. I shall enlighten you in
the following steps:
- 18. Click the gear icon.
- 19. Select the Site settings menu item.
- 20. On the site settings page, click the link for page layouts and site templates.
- 21. Scroll to the section New Page Default Settings (Figure 12).
You remember from my description of page
layouts, in an earlier section of this chapter, that page layouts
associate with a content type. Page layouts must associate with a content type because
they map the site columns of a content type to HTML markup.
As shown in Figure 12,
SharePoint has provided a list of all available page layouts from the
Master Page Gallery and their associated content types (in
parentheses). You might have noticed that different page layouts
associate with the same content type as others. Content owners create
page instances using the content type, and the site designer can choose
from a number of presentation formats, based on the chosen page layout.
For example, the Article content type associates with the page layouts
“Image on left” and “Image on right.” The content owner does not care
where the page image appears—this is the job of the site designer, and
the reason for multiple layouts. The site designer can change the page
layout of any given page as long as the content type of the page
associates with the chosen page layout.
Getting back to the example, you created a new
page instance, which defaulted to the Article content type and Body
only page layout. I will show you how to change these for the page you
just created if you did not want this content type or page layout.
- 22. Navigate back to the page view of the page you just created (Figure 11).
- 23. If you are not already in edit mode, click the gear icon and select the edit page menu item.
- 24. Click the Page tab on the ribbon.
- 25. Click the page layout icon, and SharePoint shows you a list of available of page layouts, grouped by content type.
- 26. Choose one by clicking on it (I chose one with a different content type).
- 27. SharePoint now shows you the page in the new layout.
What is nice about changing page layouts is
that SharePoint will also change the associated content type of the
page instance. The new effect is that your page instance may now have
additional site columns and may have lost some you had before. Do not
worry about content loss—if you populated with data a site column field
that is not present in the new content type, SharePoint will retain the
data, should you decide to switch back the content type and page layout.
Note The
process for creating page instances with default content type and page
layout, and then changing page layout later, is simpler than the method
required by SharePoint 2007 and 2010.