SharePoint Branding Best Bets (ATLSPUG January 2014)

Diving into the world of SharePoint branding can be a real headache. What is the best practice for deploying my branding? How do I select a design firm? What is the impact of mobile devices and how do I ensure cross-browser compatibility? What are the new branding tools available in SharePoint 2013? These are all common questions that must be answered during the course of branding efforts. In this session we’ll look at the various aspects of SharePoint branding, and common pitfalls to look out for during your next branding project.

SharePoint Branding Best Bets (SPSRIC2013)

Diving into the world of SharePoint branding can be a real headache. What is the best practice for deploying my branding? How do I select a design firm? What is the impact of mobile devices and how do I ensure cross-browser compatibility? What are the new branding tools available in SharePoint 2013? These are all common questions that must be answered during the course of branding efforts. In this session we’ll look at the various aspects of SharePoint branding, and common pitfalls to look out for during your next branding project.

Removing SPSite Property Bag Keys w/ PowerShell

I recently encountered a scenario where it was necessary to remove keys from the property bag of a site collection. Site collection properties are stored within the Properties collection on the RootWeb of the Site, but Properties.Remove(“key”) failed every time we tried it. It turns out that in addition to toggling the AllowUnsafeUpdates flag, you also must update the Properties object, then remove the key from the AllProperties collection (this was the magic piece we were missing).

$site = Get-SPSite http://path/to/site/collection
$web = $site.RootWeb
$web.AllowUnsafeUpdates = "true"
$web.Properties.Remove("_keytoremove")
$web.Properties.Update()
$web.AllProperties.Remove("_keytoremove")
$web.AllowUnsafeUpdates = "false"
$web.AllowUnsafeUpdates = "true"
$web.Update()
$web.AllowUnsafeUpdates = "false"

Once you've executed the commands above to remove the script, re-instantiate the Site and Web objects and query the AllProperties collection to ensure your key has been removed.

$site = Get-SPSite http://path/to/site/collection
$web = $site.RootWeb
$web.AllProperties

Declaratively Creating Publishing Columns

I recently needed to declaratively create site columns that used the Publishing framework for SharePoint 2010 to provide a clean UI for selection of images and links to drive publishing content. The native Link and Image field types merely provide a text box to include a URL to the link or image, and don't offer any sort of user interface for the user to select the image to be used or content to be linked. The solution here is to deploy your column using the rich HTML field types from the publishing framework (this requires publishing to be enabled on the site/web as a prerequisite).

I searched high and low trying to find documentation on how to provision these field types declaratively, and documentation was sparse. An old forum thread on MSDN got me going in the right direction, even though the post was targeted to MOSS 2007. The trick is to use the same Link and Image field types that you would use without publishing, but to also supply the RichText and RichTextMode attributes as shown below to instruct SharePoint to use the experience from the publishing framework.

Publishing Image Field

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field
       ID="{609a6675-ee62-432e-a21a-497f9db60c24}"
       Name="CustomImage"
       DisplayName="Image"
       Type="Image"
       Required="TRUE"
       Sealed="TRUE"
       RichText="TRUE"
       RichTextMode="FullHtml"
       Group="Custom Columns">
  </Field>
</Elements>

Publishing Link Field

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field
       ID="{393a29ab-f26e-4b71-bdbf-c39594c05607}"
       Name="CustomUrl"
       DisplayName="URL"
       Type="Link"
       Required="FALSE"
       Sealed="TRUE"
       RichText="TRUE"
       RichTextMode="FullHtml"
       Group="Custom Columns">
  </Field>
</Elements>