Archive

This is revision 2 of the A guide to quick SharePoint 2013 branding – part 2 – with Javascript. A few of the javasnippets turned out to stop working if MDS, Minimal Download Strategy was in affect which made the branding miss the target. The lines of javacode in this revised post has been corrected and will now work just as well with MDS.I have to send a BIG thank you to Anurag Yagnik for getting me on the right track and for verifying the functionality. THANKS!

Hi dear SharePointies and SharePoints.

Welcome to the revised part 2, the revised version has some changes and rather updating the original post, I’ll keep some history and get a new post out with slightly different content.
I assume that you have seen and followed part 1, A guide to quick SharePoint 2013 branding so I will not cover every step needed, some you will have to get from part 1.
This is for all of you SharePoint technicians and enthusiasts out there who are not developers or don’t really have time or feel like learning the new ‘Design Manager’. All of the steps here can be done using only a Windows client and appropriate permissions.

This guide has been verified in SharePoint Online. If you have done the steps in Onpremise server and/or Foundation, please drop me a comment and I will add that here and also give you credit for it.

In part 1, we added a custom masterpage, a css/stylesheet file, a favicon and a logo image. We configured SharePoint to use the custom masterpage and in that we referenced the custom css, the favicon and the logo. All good.
Now, we want to get rid of the annoying default blue ‘banner’ with the Office 365 logo(SPO), the SharePoint text (Onprem/Foundation).
Without using Visual Studio…or SharePoint Designer…

In this short guide, I will use a site located in SharePoint Online (2013/Preview, link at the end), but the steps are exactly the same in an onprem environment.

For the permanent production branding, I have to recommend using Visual Studio to create a wsp package, as long as you add the same files as I do here it will work the same. That way you will have an installable package that can be reinstalled and used in test and dev environment. You can also make sure the package works Before moving it into production.

We will in part 2, make this (pretty good):

Look like this (even better):

In my opinion, a whole lot better!
Now let’s get on with branding our site:

Use the sitecollection you used before, or simply any site collection will do. Work with the rootsite as usual.

To do what I am going to do, we need two new and one modified file:

truesec.js – New (Contains all the actual JavaScript code)TrueSec_transparent_white.png – New (New logo, White on transparent for a nice effect)truesec.master – Old (only modified to load the JavaScript file)

I will start by creating a simple JavaScript file, use a local folder to store your files in, we will later upload them to SharePoint.

Yes, you want to change the extension.
I added this JavaScript lines to my truesec.js file, see inline comments to see what it does

function ConfigureBrandingsuite(){ // Thanks to Anurag Yagnik for the enhanced script var v_icon, v_iconbox; var v_suiteBarLeftm, v_ribbonbox; var v_link; // Replace the default logo with my own shiny white with transparant background, oh-yeah! var v_newImageSrc=”../_catalogs/masterpage/truesec/TrueSec_transparent_white.png”; // get link reference so that we can point to our website, replace with your own v_link = document.getElementById(“suiteBrandingLink”); v_link.href=”https://blog.blksthl.com“; // get icon reference so that we can change properties v_icon = document.getElementById(“suiteBrandingIcon”); v_iconbox = document.getElementById(“suiteBrandingIconBox”); v_suiteBarLeft = document.getElementById(“suiteBarLeft”); v_ribbonbox = document.getElementById(“s4-ribbonrow”); // customize icon, icon box, background color and title // Setting the background of the entire suitebarleft to jet-black for maximum effect v_suiteBarLeft .style.background = “#000000”; // v_ribbonbox.style.display=”none”; // Setting the width to a little more than default, else the image may be cropped v_iconbox.style.width=”200px”; v_icon.src = v_newImageSrc; v_icon.style.width=”150px”; v_icon.style.left=”0″; v_icon.style.top=”0″; v_icon.alt=”Go to My Portal”; v_icon.title=”Go to My Portal”; // site specific – hide logo since we already have on on top left now //document.getElementById(“ctl00_onetidHeadbnnr2″).style.display=”none”; return false;}

Make sure that your quotes and double quotes are correct, copying from a webpage often result in misformatted quotes. Avoid this by reviewing the code thoroughly in notepad. The ‘wrong’ kind usually leans to one or the other direction, whilst the ‘correct’ kind are straight. Example:

Ok, thats one out of three files, moving on to the masterpage.
This you may allready have stored locally, but if you don’t, download a copy from SharePoint. I’ll use my custom truesec.master from part 1.

Make sure that your quotes and double quotes are correct, copying from a webpage often result in misformatted quotes.
Avoid this by reviewing the code thoroughly in notepad. The ‘wrong’ kind usually leans to one or the other direction, whilst the ‘correct’ kind are straight.
Example:

With the code added, that part of the masterpage will now look like this:

Save the file and leave it for now. We will upload all the files later.

So, two out of three done.
Time for the simplest one, the image. I wanted to add something a bit different than the logo I have already added, so I went with a logo in white on black instead of black on white. The image file is White on transparent and then the java script sets the background to jet-black which makes it all perfect. You use the images you want and for your customer/company/organization and make the decisions based on the colors you have there, I bet it will be beautiful!

Ok, if you started out like I did with the ‘light branding’ already in Place, then you are pretty much done, all we need to do is upload the files and reload the page to see the result. Go to your site, open ‘Site settings’, ‘Master page’, browse to your folder, in my case its ‘/TrueSec’. Once here, select the ‘Files’ tab and ‘Upload Document’.

Now, if you already had the custom master selected in the site, it will load automatically with the JavaScript and all. Load the site in a browser to see the result:

If any of the branding does not show up, one good T-shooting step is to go to the MasterPage gallery again and the ‘truesec’ folder. In here, click on the dropdown for each file and make sure they are all published, if you get the option to ‘Publish a major version’ do it. That helps a lot of times when anything is wrong.
If anything is so wrong so that you can’t access any of the sites, use this link: [URL to your team site]/_layouts/15/ChangeSiteMasterPage.aspx, it will allow you to switch back to the ‘Seattle master’ and get access to the libraries and settings again. Make Changes, fix the problem, upload the new file and switch back to your custom master again to test.

Where to go from here?
In addition to the objects I have modified using java, there are several you can figure out how to configure for yourselves. If you want to find the objects, you can use F12 – Developer Toolbar that is built into IE.
Or, use any of these that are part of the 2013 default objects:suiteBarLeft
suiteBarRight
suiteBrandingBoxDeltaSuiteLinkssuiteBarRightRibbonContainer-TabRowRight

All og these have different properties to be configured, google, test, play around and find out what can be done.

Specifies the URL or GUID of the Web to be exported. The type must be either
– a valid GUID, in the form ‘12345678-90ab-cdef-1234-567890bcdefgh’
– a valid name of a SharePoint site (for example, MySPSite1)
or a URL: http://blog.blksthl.com
or an instance of a valid SPWeb object

Path

Required

Specifies the name of the export file. If the -NoFileCompression parameter is used, a directory must be specified; otherwise, any file format is valid.
Example: “c:\temp\exportedsite.cmp” or with the -NoFileCompression “c:\temp\exportedsite\”

AssignmentCollection

Optional

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

Note:

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

CompressionSize

Optional

Sets the maximum file size for the compressed export files. If the total size of the exported package is greater than this size, the exported package will be split into multiple files.

Confirm

Optional

Prompts you for confirmation before executing the command. For more information, type the following command: get-help about_commonparameters

Force

Optional

-Force Forcefully overwrites the export package if it already exists.The type must be either of the following values:
–True–FalseThe default value is False.

HaltOnError

Optional

Stops the export process when an error occurs.

HaltOnWarning

Optional

Stops the export process when a warning occurs.

IncludeUserSecurity

Optional

Preserves the user security settings except for SPLists that have broken inheritance and item level permissions set.
(Use Import-SPWeb with –IncludeUserSecurity to preserve security on import)

IncludeVersions

Optional

Indicates the type of file and list item version history to be included in the export operation. If the-IncludeVersions parameter is absent, the Export-SPWeb cmdlet by default uses a value of CurrentVersion. The type must be any one of the following versions:LastMajor “Last major version for files and list items (default)”CurrentVersion “The current version, either the last major version or the last minor version”LastMajorAndMinor “Last major and last minor version for files and list items”All “All versions for files and list items”

ItemUrl

Optional

Specifies the relative path to the object to be exported. Can also be a GUIDThe type must be a valid relative path, for example, /Subsite/Documents
or a valid GUID in the form: 12345678-90ab-cdef-1234-567890bcdefgh

NoFileCompression

Optional

Either enables or disables file compression in the export package. The export package is stored in the folder specified by the Path parameter or Identity parameter. We recommend that you use this parameter for performance reasons. If compression is enabled, the export process can increase by approximately 30 percent.

NoLogFile

Optional

Suppresses the generation of an export log file. If this parameter is not specified, the Export-SPWeb cmdlet will generate an export log file in the same location as the export package. The log file uses Unified Logging Service (ULS).It is recommended to use this parameter. However, for performance reasons, you might not want to generate a log file.

UseSqlSnapshot

Optional

Specifies a SQL Database Snapshot will be created when the export process begins, and all exported data will be retrieved directly from the database snapshot. This snapshot will be automatically deleted when export completes.

WhatIf

Optional

Displays a message that describes the effect of the command instead of executing the command. For more information, type the following command: get-help about_commonparameters