Beruflich Dokumente
Kultur Dokumente
Branding for
SharePoint
2010
A complete branding solution shell including a
simplified, simple, optimized Master Page and a
Visual Studio 2010 Brand Solution for packaging
your Branding elements into an easy to deploy
SharePoint Feature for the farm or a sandbox.
Version 1.0
Version 1.0
By Eric Overfield
PixelMill
Blog.pixelmill.com/ericoverfield
Twitter.com/ericoverfield
PixelMill, Inc.
Page 2
PixelMill, Inc.
Page 3
Solutions
Why do I have two solutions here? Well because there are pros and cons with both farm based and sandboxed
solutions. I find that it is best to give you arguments for and against each and let you decide. Either way you
have a starter project to work with.
Page 4
Your solution does not run in an independent environment so security is more of a concern.
If you update the solution it will update for all instances. Again this could be a pro, but you might
want to update only one installation of the solution.
Must be installed via PowerShell by an account with the proper Administrative access.
Cannot be installed into a shared environment including Office 365 or many shared hosting
services.
A solution built without sandboxing in mind may be difficult to covert to be sandboxed friendly.
PixelMill, Inc.
Page 5
Install the Jumpstart Master Page (Basic) Server Sites or Sites with
Publishing Enabled
1. Open your Site Collection (or a sub site if you want to install the Master Page only to a sub site) in SPD.
2. Go to the root of your site. Click on All Files found in the left navigation.
PixelMill, Inc.
Page 6
3. Open the Masterpage Galleries folder in SharePoint Designers by going to _catalogs -> masterpage
under All Files.
4. Drag and drop the Master Page file, v4-JumpstartBranding-basic.master to the folder location,
_catalogs/masterpage.
5. Right click the newly uploaded Master Page and click on Check In.
6. In the Check In window choose Publish as a Major Version. Click "OK".
7. When asked to approve the page, click "yes". This will open a browser window with all your pending
pages to be approved.
8. Before approving our newly uploaded Master Page, we need to set the correct page content types.
Right-click the newly uploaded Master Page and choose Edit Properties. You'll be asked to check out
the page before making changes. Click "OK" to edit the item.
9. When the dialog box opens, make sure the following are selected:
a. Content Type should be Publishing Master Page
b. Compatible UI Version should be 4
10. Then Click "OK".
11. While still in the browser, right-click the new Master Page to Check In the item. You'll get the option for
what type of version you would like to check in. Choose Major Version, which will also publish the
item. If, the file is already checked in, then right-click and select Publish as Major Version
12. After the Master Page is Checked In and Published as Major Version, you can approve the page. On
the same page, right-click and select Approve/Reject. In the dialog box, select Approved. Then Click
"OK".
13. Now navigate to your root site collections Site Settings page (Or the sub site you installed this template
to), by going to Site Actions (usually found in the top left of your header area and ribbon) -> Site
Settings
14. On your Site Settings page, in the right column under Look and Feel click on Master page. This will
load the url, http://yoursite/_Layouts/ChangeSiteMasterPage.aspx.
15. In the Site Master Page section select the new Master Page from the drop down menu if you would
like to set this new Master Page as your Custom Master page. In publishing sites your custom Master
Page is used for any content page you create that by default goes into the Pages folder.
16. In the System Master Page section select the new Master Page from the drop down menu if you would
like to set the new Master Page as your Default Master page. This would be the master page used for
system pages like your Site Settings Page.
17. If you would like sub sites to inherit either of these two Master Pages be sure to check Reset all
subsites to inherit this site master page setting.
18. You can ignore the Alternate CSS URL section for now for this Basic Jumpstart Master Page.
19. That is it, your site should now be using your new Master Page.
PixelMill, Inc.
Page 7
Page 8
Install the Jumpstart Master Page (Centered, Fixed Width) Server Sites or
Sites with Publishing Enabled
1. Open your Site Collection (or a sub site if you want to install the Master Page only to a sub site) in SPD.
2. Go to the root of your site. Click on All Files found in the left navigation.
3. Open the Masterpage Galleries folder in SharePoint Designers by going to _catalogs -> masterpage
under All Files.
4. Drag and drop the Master Page file, v4-JumpstartBranding-centered.master to the folder location,
_catalogs/masterpage.
5. Go to the root of your site. Click on All Files found in the left navigation.
6. Open your Style Library folder in SPD by going to the Style Library folder.
7. In the Style Library folder, if there is not a Themable directory then create one (right click folder and
select New -> Folder).
8. Drag and drop the stylesheet, styles-centered.css to the folder location, Style Library/Themable.
a. The reason why we place the styles-centered.css file in the Themable folder is so that
SharePoint can apply a theme to the stylesheet if you wanted to.
9. Right Click the new stylesheet and click on Check In.
10. On the Check In window, choose Publish as a Major Version. Click "OK".
11. In the Style Library folder, if there is not a Scripts directory then create one (right click folder and select
New -> Folder).
12. In the Scripts directory your just created, create a new directory, JumpstartBrandingSandbox.
13. Drag and drop the two .js files, jquery.1.7.1.min.js and jquery.custom.js, to the folder location, Style
Library/Scripts/JumpstartBrandingSolution.
14. Right Click each of the two new .hs files one at a time and click on Check In.
15. On the Check In window, choose Publish as a Major Version. Click "OK" for each .js file.
16. Go back to the _catalogs/masterpage folder and Right Click the new Master Page
17. Right click the newly uploaded Master Page and click on Check In.
18. In the Check In window choose Publish as a Major Version. Click "OK".
PixelMill, Inc.
Page 9
19. When asked to approve the page, click "yes". This will open a browser window with all your pending
pages to be approved.
20. Before approving our newly uploaded Master Page, we need to set the correct page content types.
Right-click the newly uploaded Master Page and choose Edit Properties. You'll be asked to check out
the page before making changes. Click "OK" to edit the item.
21. When the dialog box opens, make sure the following are selected:
a. Content Type should be Publishing Master Page
b. Compatible UI Version should be 4
22. Then Click "OK".
23. While still in the browser, right-click the new Master Page to Check In the item. You'll get the option for
what type of version you would like to check in. Choose Major Version, which will also publish the
item. If, the file is already checked in, then right-click and select Publish as Major Version
24. After the Master Page is Checked In and Published as Major Version, you can approve the page. On
the same page, right-click and select Approve/Reject. In the dialog box, select Approved. Then Click
"OK".
25. Now navigate to your root site collections Site Settings page (Or the sub site you installed this template
to), by going to Site Actions (usually found in the top left of your header area and ribbon) -> Site
Settings
26. On your Site Settings page, in the right column under Look and Feel click on Master page. This will
load the url, http://yoursite/_Layouts/ChangeSiteMasterPage.aspx.
27. In the Site Master Page section select the new Master Page from the drop down menu if you would
like to set this new Master Page as your Custom Master page. In publishing sites your custom Master
Page is used for any content page you create that by default goes into the Pages folder.
28. In the System Master Page section select the new Master Page from the drop down menu if you would
like to set the new Master Page as your Default Master page. This would be the master page used for
system pages like your Site Settings Page.
29. In the Alternate CSS URL section, select Specify a CSS file to be used by this publishing site and
all sites that inherit from it: and either browse or enter the path to the new stylesheet we uploaded.
By default this would be /Style Library/Themable/styles-centered.css.
a. Note: Be sure path value includes the full path to your stylesheet. If you are installing this to a
sub site collection that has the path http://yourwebapplication/sites/subsitecollection then the
path value would be /sites/subsitecolllection/Style Library/Themable/styles-centered.css.
30. If you would like sub sites to inherit either of these two Master Pages or the Alternate CSS URL be sure
to check Reset all subsites to inherit this site master page setting.
31. That is it, your site should now be using your new Master Page.
PixelMill, Inc.
Page 10
Page 11
3.
4.
5.
6.
b. Replace http://yoursitecollection/ with the path to your site collection you are installing this
Sandbox solution to.
Add-SPUserSolution -LiteralPath c:\temp\JumpstartBranding.wsp -Site http://yoursitecollection/
Install-SPUserSolution Identify JumpstartBranding.wsp -Site http://yoursitecollection/
Go to your Site Collection Features page and activate the Jumpstart Branding Sandbox feature at
http://yoursitecollection/_layouts/ManageFeatures.aspx?Scope=Site
That is it. The Jumpstart Branding Feature is now activated on your site collection
Page 12
PixelMill, Inc.
Page 13
PixelMill, Inc.
Page 14
A few additional files are required for this Master Page including a custom stylesheet. For installation
instructions please refer to the previous section. This stylesheet not only creates the centered, fixed width side
but also changes a few colors, adds a border and finally adds padding to the bottom of the site. All of these
changes can be easily modified or removed, but were added to provide you additional examples of what can
be done and how. This stylesheet should go in a Themable directory to take advantage of the theming engine
built into the stylesheet.
Two Javascript files are also required, jquery-1.7.1.min.js and jquery.custom.master. By default the Master
Page is looking for these files in the ~SiteCollection/Style Library/Scripts/JumpstartBrandingSandbox/
directory. You can modify this as you need to just be sure to change the ScriptLink tags in the Master Page.
The jquery-1.7.1.min.js file provides the basic jquery library. You can change this if you want to a different
version.
NOTE: This jquery library changes the normal jQuery tag $() to $j(). This is because SharePoints OOTB js
files sometimes use $() for its own purposes, meaning that if we let jQuery use $() as well then we can run into
unexpected site problems.
The second js file, jquery.custom.js provides as simple technique as possible to fix a well known issue with
SharePoint fixed width sites, that being that many administration pages and List View pages have a tendency
to overflow a centered, fixed width site. This code loads every time a page loads and checks to see if any
content is wider than the #s4-bodyContainer container. If it is then it resizes the fixed width site to fit the
content. The Javascript that handles the width issue is very lean, it normally only has to search 2-5 different
elements, which on my machine takes about 2 milliseconds when tested using a simple debugging timer.
PixelMill, Inc.
Page 15
There are two Master Pages and one Page layout included in the MasterPageGallery module. By default the
v4-JumpstartBranding-centered.master is set as the default and custom Master Pages during activation.
Instructions on how to change this are listed below.
During activation the feature will set the new Master Pages, set the Alternate CSS to styles.css file found in the
Style Library module and will also remove any currently set theme as with a theme applied the new Master
Page may not work correctly because the theme files may not yet exist. You can simply reset the theme if you
would like.
By default all files (Master pages, Page Layouts, Images, Style Sheets, etc) should be added to a directory, by
default JumpstartBranding as set in by the sBrandingFolder variable in the feature receiver class. This is
used to help find and remove files when the feature is deactivated.
In the Feature Receiver class, you will also see a variable, bDeleteDuringDeactivate. When set to true, by
default, then all files added during activation will be removed upon deactivation. This is highly recommended
for housekeeping purposes.
PixelMill, Inc.
Page 16
We are telling SharePoint that this file should be Ghostable, that its for V4 and that the content type
is a Master Page (0x010105)
b. Page Layout
<File Url="your-page-layout.aspx" Path=" your-page-layout.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="Your Title" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingAssociatedContentType"
Value=";#$Resources:cmscore,contenttype_articlepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E
9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#" />
</File>
We are telling SharePoint that this file should be Ghostable, that the content type is a Page Layout
PixelMill, Inc.
Page 17
Add Additional Script Files to the Layouts Mapped Directory (Farm) or Style Library (Both)
1. Add your new file or copy your file into your preferred Mapped directory or Style Library module. A few
notes, dont forget that for sandboxed solutions you cannot used the Layouts or Images Mapped folder.
Also, if you do use the Layouts or Images mapped folders then it can be more difficult to change the
files in the future using SPD. This is good or bad depending on what control you want to give to
designers after a feature has been activated.
2. By default the Elements.xml file in the Module or Mapped Directory will be updated to reflect the new
file you added, but most likely not correctly.
3. Open the Elements.xml file in the module or Mapped directory in question.
4. Add Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" to the <File> element that was just added, i.e.
<File Path="Style Library\Themable\JumpstartBranding\styles.css" Url="Themable/JumpstartBranding/styles.css"
Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />
Allowing the file to be Ghostable can help with performance while adding IngoreIfAlreadyExists allows
the file in question to not fail an activation if the file already exists. Now according to SharePoint
documentation settings this value to true will mean that if the file exists then it will be overwritten with
the new file. That is not true. This is why both solutions included in JumpstartBranding for SP2010
include code during deactivation to remove all files that were added during activation as this is not done
automatically.
Add Additional Images to the Layouts Mapped Directory (Farm) or Style Library (Both)
1. Follow the steps in the previous section on adding the image(s) to your desired location including
modifying the elements.xml file.
2. You now need to link to your image(s) in your stylesheet.
3. Open your stylesheet, by default for these solutions found in the Style Library module.
4. Say the image is in the Style Library module, i.e./Style Library/Images/JumpstartBranding/image.png
and your style sheet is in the same module, i.e.
/Style Library/Themable/JumpstartBranding/styles.css, then your url tag in the stylesheet would look
like:
url(../../Images/JumpstartBranding/image.png)
PixelMill, Inc.
Page 18
module or folder (i.e. the MasterPageGallery module or Style Library Module). This is so that it is easier to
clean up the feature when it is deactivated.
1. Open the project (for this example JumpStartBranding.csproj) in Visual Studio 2010.
2. Click on the right arrow next to the Style Library module to have the Style Library directory tree
display.
3. Right-click Style Library if the en-us directory does not exist. Mouse-over New in the drop down menu,
then in the New sub menu click Folder.
4. Rename the new folder, en-us.
5. Following the same procedure as above create a new Folder, Themable in the en-us directory as well
as a JumpstartBranding folder in the Themable folder.
6. Drag and drop the styles.css file from the /Themable/JumpstartBranding directory to the enus/Themable/JumpstartBranding directory.
7. Double-click the Elements.xml file found in the root of the Style Library module.
8. Although the Elements.xml should have been updated for you, for this example, verify that the new
<File> element for this file changed to:
<File Path="Style Library\en-us\Themable\styles.css" Url="en-us/Themable/styles.css" Type="GhostableInLibrary"
IgnoreIfAlreadyExists="TRUE" />
9. For this example, the Path value will need the full path to the file were as the Url does not. This is
because in the Module element we already specified the primary directory of the Url.
10. You can use this same strategy to change the install directory of files in the Layouts and Images
shared folders as well as the Style Library module.
If you wish to change the sub directory name that assets will be installed in
For this example we will assume that you want to change the sub directory name that assets are installed
to from JumpstartBranding to YourNameHere. First, you will want to rename the directory names in the
modules and/or shared folders as explained above.
1. Open the JumpstartBranding.EventReceiver.cs file found in the JumpstartBranding feature.
2. Around line 32 look for the line.
String sBrandingFolder = "JumpstartBranding";
Page 19
References
Primary references for the Jumpstart Solution include the following:
Starter Master Pages for SharePoint 2010 by Randy Drisgill
http://startermasterpages.codeplex.com/
Deploying Branding Solutions for SharePoint 2010 Sites using Sandboxed Solutions by Ted Pattison
http://msdn.microsoft.com/en-us/library/gg447066.aspx
SharePoint 2010 CSS Reference Chart by Heather Solomon
http://sharepointexperience.com/csschart/csschart.html
Please also refer to many references that have been added in the code itself for specific code examples of
similar code blocks that I either used for inspiration or I found after the fact while producing Jumpstart Branding
for SharePoint 2010.
There are many other references that I am sure I am leaving out because I either havent recorded the address
of the reference, or I dont remember who the reference might have been. I apologize to those that have
contributed to the SharePoint community and were likely a part of my SharePoint education, including sites,
blogs or references that I learned from over the years but and not specifically thanking.
PixelMill, Inc.
Page 20