Creating a custom composed look
Composed looks are stored as items in the _catalogs/design
list within each SharePoint site. They can specify the master page, color palette, font scheme, background image, and display order in relation to other composed looks.
How to do it...
Follow these steps to create a custom composed look:
- Navigate to the site in your preferred web browser.
- Select Site settings from the Settings menu.
- Select Composed looks in the Web Designer Galleries section.
- Click on New Item to create a new composed look item in the list.
- Enter the name for the composed look in both the Title and Name fields.
- Enter the URLs to the master page, color palette, background image, and font scheme files in both the Web Address and Description fields for each section.
- Enter the Display Order.
- Click on Save.
How it works...
Composed looks are simply stored as items in the _catalogs/design
list. When a composed look is applied to a site the items specified in the composed look are used to create a SPTheme
object that then gets applied to the SPWeb
object representing the site. If no background image is specified, none will be applied when using this composed look. If no font scheme is specified, the default SharePointPersonality.spfont
font scheme will be applied when using this composed look.
Lastly, the Display Order option is used to sort the available composed looks when choosing which composed look to apply to a site. Have a look at the following screenshot:
There's more...
A composed look can be created with PowerShell or code using the server-side object model.
Follow these steps to create a custom composed look using PowerShell:
- Get the site using the
Get-SPWeb
Cmdlet:$web = Get-SPWeb http://sharepoint/site
- Get the
SPList
object representing the_catalogs/design
list from theSPWeb
object:$list = $web.Lists["Composed Looks"]
- Add a new
SPListItem
to theItems
collection of theSPList
object:$item = $list.Items.Add()
- Assign the values to each of the properties of the
SPListItem
object:$item["Title"] = "PowerShell" $item["Name"] = "PowerShell" $item["Master Page URL"] = "/_catalogs/masterpages/seattle.master" $item["Theme URL"] = "/_catalogs/theme/15/palette005.spcolor" $item["Image URL"] = "/_layouts/15/images/image_bg005.jpg" $item["Font Scheme URL"] = "/_catalogs/theme/15/fontscheme003.spfont" $item["Display Order"] = "200"
- Use the
Update
method onSPList
to update theItems
collection:$item.Update()
- Use the
Dispose
method to discard theSPWeb
object:$web.Dispose()
Follow these steps to create a custom composed look with code using the server-side object model:
- Open the site collection containing the site in a
using
statement:using (var site = new SPSite("http://sharepoint/site"))
- Open the site in a
using
statement:using (var web = site.OpenWeb())
- Get the
SPList
object representing the_catalogs/design
list from theSPWeb
object:var list = web.Lists["Composed Looks"];
- Add a new
SPListItem
to theItems
collection of theSPList
object:var item = list.Items.Add();
- Assign the values to each of the properties of the
SPListItem
object:item["Title"] = "PowerShell"; item["Name"] = "PowerShell"; item["Master Page URL"] = "/_catalogs/masterpages/seattle.master"; item["Theme URL"] = "/_catalogs/theme/15/palette005.spcolor"; item["Image URL"] = "/_layouts/15/images/image_bg005.jpg";
item["Font Scheme URL"] = "/_catalogs/theme/15/fontscheme003.spfont"; item["Display Order"] = "200";
- Use the
Update
method on theSPList
object to update theItems
collection:item.Update();
See also
- The Themes overview for SharePoint 2013 article on MSDN at http://msdn.microsoft.com/en-us/library/jj927174.aspx
- The How to: Add or Delete List Items article on MSDN at http://msdn.microsoft.com/en-us/library/ms467435(v=office.14).aspx
- The SPWeb class topic on MSDN at http://msdn.microsoft.com/en-us/library/Microsoft.SharePoint.SPWeb.aspx
- The SPSite class topic on MSDN at http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.aspx
- The Get-SPWeb topic on TechNet at http://technet.microsoft.com/en-us/library/ff607807.aspx