Friday, November 25, 2016

Sharepoint 2013 Change Sharepoint Branding text in Top Left

In Sharepoint instance, we see a branding text 'SharePoint' on top left corner of the page.

There are multiple ways to change this text to our organization branding. Few of the easy approaches are as below.

Approach 1: Using Powershell.
In Powershell, we have a property SuiteBarBrandingElementHtml for webapplication using which we can read and set the Branding Element HTML. Use below code to read and set the text.
 #Add powershell snapin  
 Add-PSSnapin microsoft.sharepoint.powershell  
 #Get web application  
 $webApp = Get-SPWebApplication http://metisqa.broadridge.net/  
 write-host "Original Branding Text"  
 #read brand elemnt html  
 write-host $webApp.SuiteBarBrandingElementHtml  
 #Set Branding Element HTML. can include styles / class file as below   
 $webApp.SuiteBarBrandingElementHtml = "<div class='ms-core-brandingText'>Your Company Name</div>"  
 #Update the webapplication to reflect above changes  
 $webApp.Update()  
 write-host "Updated Branding Text"  
 #read existing brand elemnt html  
 write-host $webApp.SuiteBarBrandingElementHtml  

We can also set Images / hyper links in the branding text by simply setting the required HTML tagged text.

Approach 2: Using CSS
As the Branding text tag holds as CSS Class 'ms-core-brandingText', we can update styles around this class and change display  using 'Content' style attribute.
 .ms-core-brandingText:after  
 {   
      content:"Your company Name";  
      padding-left:10px;  
 }  
 .ms-core-brandingText{  
      margin-left: -95px;  
 }  

In this approach we can set images using css property background-image, but can't set any links to the branding element.

Approach 3: JavaScript / JQuery
Update html text in the html branding text tag. this can be achieved easily using the CSS class 'ms-core-brandingText'
 //Jquery code to set branding text  
 $('.ms-core-brandingText').html('Company Name');  
Here, we can also set image / hyper links by setting required html content in above code.

By using any of the above approached, it appears as below.


No comments:

Post a Comment