Tag Archives: Branding

How to add the “Contact Us” gadget to your Office 365 Publishing Site

This follows on from my previous post which describes how to enable the Publishing Features for your Office 365 website and resolving issues with Custom Master Pages in Office 365.

Having done that on my own site (www.hatchsolutions.co.uk) I found that one of the key “Gadgets” was missing .. the Contact Us form.

This was an immediate conundrum.. Sandbox Solutions do not allow email access so I knew I couldn’t use that as an out, so I thought I would hunt down that Gadget.

STEP 1 – Add Office 365 namespaces to your Custom Master Page
This is a pre-requisite, as you will be using some of the “Office 365” web controls. I found these in the header of the “oob” root.master which you will find in the All Files section of your public website in SharePoint Designer.

Add these to the top of your Custom Master Page.

<%@ Import namespace=”Microsoft.SharePoint.Spx.WebSite.Controls” %>
<%@ Import namespace=”Microsoft.SharePoint.Spx.WebsiteCore” %>
<%@ Import namespace=”Microsoft.SharePoint.Spx.WebsiteCore.Controls” %>

(note the special Microsoft.SharePoint.Spx namespace!)

STEP 2 – Create Custom Page Layout with Contact Us Control Embedded
This was the way I chose to do it .. you don’t have to do the same (although I couldn’t work out an easier way of doing this myself).

I created a new custom Page Layout (based from one of the others). I deliberately removed any references to any custom code-behind or code-blocks.

This means that I will be running OOB code, and won’t be consuming any Sandbox Resource points!

Then add the following ASP.Net snippet into your page:

<iws:ContactUsControl runat=”server” EmailTo=”info@hatchsolutions.co.uk” CultureName=”en-US” SendToBCM=”on” xmlns:iws=”iws” />

This is the same ASP.Net tags that get used when you drop the gadget onto your page.
You can see in my example I have added my own EmailTo and CultureName attributes .. you can set these to whatever is appropriate.

The other thing to note is that you must place this control in an EditModePanel with PageDisplayMode=”Display”. The Contact Us form otherwise tries to validate the page when you try and Save Changes or Publish (not good!)

And that is it .. simply save your changes, publish your page layout and create your own page! 🙂
I have created my own custom page layout here;

Please let me know how you get on with yours!

Office 365: Custom Master Page – Resolving “Code blocks are not allowed in this file”

This was an annoying error for quite some time. Office 365 (SharePoint Online) gives you full control to create, deploy and select custom master pages, but if you try using them you often get the error:

Code blocks are not allowed in this file

The reason for this is because of the locked down security permissions in the Master Page Gallery. This is fair enough, just means you can’t have custom code running on your Master Page (but seriously .. how often do you actually need to do that?)

So .. I created my Master Page using the awesome CodePlex Starter Master Pages. And this was fine until I deployed it (using Sandbox Solutions) to my Office 365. Bam .. error message (Code blocks are not .. blah blah).

Well .. I went through my Master Page line by line .. I couldn’t actually FIND any code blocks. I could find a bunch of expressions (but these don’t count!) such as

  • <%@ Import %>
  • <%@ Register %>
  • <%$Resource ..>

The Resource tags reference resource strings. This is used ALL over the OOB controls and is generally very good practice!

I finally worked out what was causing it .. the actual Master page tag itself!
    <%@ Master language=”C#” %>

The “language” attribute was causing all of the problems! (even though we didn’t have any code!)

So I removed the language attribute (leaving me with):

    <%@ Master  %>

And hurrah! I all started working. Hope this helps! Happy branding!

How to configure your Office365 public website to use the SharePoint Publishing Infrastructure

Important Update (2nd September 2011) – Microsoft have announced that this is NOT SUPPORTED. Please see the following post: Update – Publishing Features “not supported” on Office 365 Public Websites

This is something that has bugged me for a LONG time .. I cannot possibly understand why SharePoint Online (with one of the most powerful Web Content Management Systems) was so thoroughly limited by cutting back to a really basic template editor. I can only think of 2 reasons:

  1. Microsoft assumes the average user won’t know how to use SharePoint, so wanted to provide a simpler user interface. This is fair enough, and if this IS the reason there should be no reason why I can’t go “behind the scenes” and setup the site any way I like (at my own risk .. as it were).
  2. Microsoft is trying to protect revenue from “SharePoint 2010 Server Internet Facing Sites” licenses. These are VERY expensive and a lot of companies will happily get rid of their on-premise install to put in a £80 a year Office 365 E1 plan to host their website.

Now .. if it is case (1) then we should be good to go. If it is case (2) then they probably have terms and conditions specifically stopping someone from doing this… so first off lets get the disclaimer out of the way 🙂

Disclaimer Update (26th July 2011) – I have received confirmation from Microsoft via the Office 365 community site that this IS ALLOWED (https://community.office365.com/en-us/f/153/p/8015/34893.aspx#34893). Having said that if you decide to do this in your own environment then proceed at your own risk! If something goes wrong it is NOT my fault .. you have been warned!

Ok .. now that is dealt with lets get on with it!
The first thing I want to note is that this is only possible using an Enterprise Plan. If you are using the Small Business version of Office 365 (such as Plan P1) then you won’t be able to do this for 2 major reasons:

1) SharePoint Designer blocks access to “All Files” so you can’t make some of the changes we need to do.
2) You don’t have access to Site Collection Features, so you can’t activate the Publishing Infrastructure Feature!

So I setup my own trial Enterprise Plan (with a 30 day expiry .. hence why I haven’t bothered posting the URL) and created the standard “Public Website” site collection… then what?

STEP 1 – SharePoint Designer – Rename the Public Website Folders
This is the first fundamental step. If you don’t do this then STEP 2 will throw errors at you (because folders using “Pages” for example, already exists!).

Open your site in SharePoint Designer 2010 (free download) and click on “All Files” (should be the bottom link in the left-hand navigation panel).

This will show you the URL paths being used by each of the lists and libraries. You cannot delete these (as the delete option is prohibited) but you can rename them!
RENAME each of the following libraries (I have prefixed mine with OLD).

  • Documents
  • Images (the root folder)
  • Pages
  • SiteImages (the library)
  • TemplateGallery

None of these will be required once you have activated the publishing features.

Next, go to “Lists and Libraries” (second link from top left hand side). This will show you the NAME of the same lists and libraries.
RENAME each of the following libraries (again, I have prefixed mine with OLD).

  • Documents
  • Web Pages
  • Templates
  • Images

 Your site is now primed for the publishing features to be activated (if you navigate to your website URL now, you would be taken to the blank “default.aspx” page).

STEP 2 – Activate Publishing Features
Navigate to your website and append “/_layouts/settings.aspx” onto the end
e.g. https://martinhatch-web.sharepoint.com/_layouts/settings.aspx

You will need to activate 2 features in this order:

  1. Site Collection Features – SharePoint Server Publishing Infrastructure
  2. Site Features – SharePoint Server Publishing

So you now have “publishing” functions available!

STEP 3 – Create default Page
This is really optional, and anyone familiar with SharePoint should be happy from this point onwards.

  • New Page is now available from Site Actions. This will create a new Publishing Page
  • Using the Master Page options in Site Settings change the Site Master Page (I have used NightandDay.master in the screenshot below). You can of course create and deploy your own custom master pages using either SharePoint Designer or Sandbox Solutions.
  • Advanced Navigation options are now available from Site Settings.
  • The Pages library supports Content Approval, Publishing workflows and scheduling!

And that is it .. all done 🙂

The only problem with this is we now have a bunch of old libraries hanging around which we can’t get rid of.
I’m sure there is a neat way using a Sandbox Solution or client object model to delete those forcibly, and setup all of this, but for now I’m putting up with a bunch of old libraries prefixed with “OLD” (which don’t contain anything).
The other thing in the mean time is finding out if Microsoft are actually willing to let us do this? I really hope they are .. it does expose the awesome power of SharePoint to the masses .. but will it mean they sacrifice some of the on-premise installs?? fingers and toes remain crossed.

Note – I have started a forum thread asking this specific question. We shall see !!

Page Title element and PerformancePoint Report always being blank

This was one I came across recently while doing some custom branding work on a SharePoint 2010 site which was using Performance Point Services, and specifically the PerformancePoint Report Web Part.

I had a simple branded master page (which was a copy of the normal v4.master) but could not for the life of me get PerformancePoint reports to work.

The Report Web Part was blank (with zero height) and there was a JavaScript error on the page:

Unterminated string constant
Code: 0

Well .. I rolled my site back to the v4.master and it was working again. I copy-pasted the v4.master <head> contents into my custom master page and it started working again .. although when I double checked the contents they were IDENTICAL.

So far this was very very weird .. and the actual solution is even weirder.

It seems it was to do with my <title> element in the <head> tags being broken onto separate lines:

   <asp:ContentPlaceHolder id=”PlaceHolderPageTitle” runat=”server” />

<title><asp:ContentPlaceHolder id=”PlaceHolderPageTitle” runat=”server” /></title>

Why?? I have no idea .. but making this simple change solved the problem.
Bizarre eh?

Tip – Apply Branding in WSS 3.0

Here’s a quick tip, cos I don’t have loads of time.
We’ve had lots of enquiries from our clients about Branding in WSS 3.0. If you are running MOSS 2007 then you have all of the nice “Look and Feel” settings when you go to Site Settings, allowing you to not only change the Master Page and Style Sheet, but also to push those changes down through the rest of the Portal.
Well … to put it bluntly, WSS 3.0 won’t let you do any of that.
So .. how about creating a Branding Feature?
You can write custom event handlers for Features (called Feature Receivers, using the SPFeatureReceiver class), so that you can have code that executes when a Feature is Installed, Activated, DeActivated or Uninstalled.
I won’t go into the details here, but there are some great articles about this on the web and MSDN.
So hows this for an idea?
Write yourself a Feature that applies Branding to WSS 3.0 sites (or any site for that matter!). You can make it set a new Master Page, change the Style Sheet, the Logo, set a custom “Site Theme” or even just inherit all those properties from the Parent site.
One great use (that we use quite regularly) is to create a Hidden Feature that just applies the Parent Site’s branding settings to the new site. You can then use Feature Stapling to make sure that ANY (staple to “GLOBAL”) site that gets created will be branded .. you don’t need to worry about the site definition!
As for the values used for the Branding, well you can pass these in as “Properties”. Every feature can have them, and they are specified as follows (in the Feature.xml file).
<?xml version=”1.0″ encoding=”utf-8″ ?>
<Feature xmlns=”https://schemas.microsoft.com/sharepoint/
      <Property Key=”NewMasterPage” Value=”/_layouts/CustomBranding/NewMasterPage.master”/>
So in that feature we have specified a Property called “NewMasterPage” (you can have as many of these as you like).
Then … to get that Property value out in your Feature Receiver you can use the following line of code:
string strMasterUrl = ((SPFeatureProperty)properties.Feature.Properties[“NewMasterPage”]).Value;
If the property doesn’t exist, or the value is blank then it will return an empty String (so you shouldn’t need to worry about null reference exceptions!)
Then, all you need to do is change the SPWeb property and call SPWeb.Update() to apply the changes! For example:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
// apply branding
using (SPWeb web = (SPWeb)properties.Feature.Parent)
   web.MasterUrl = strMasterUrl;
Hope this gives you some good starting points! You might want to extend this further; here are some interesting things you might do:
  • Add a Property Flag to reset all sub-site branding settings. This can then be activated at the top level to reset all branding Site Collection wide.

  • Add an “inherit from Parent” Property. Then you can use SPWeb.ParentWeb to get the parent SPWeb object (and all of it’s branding settings).

  • Store the “original” branding settings (before you overwrite them) in the SPWeb.Properties hashtable. Then, add an “DeActivating” event, and put all the original properties back again! (so when you deactivate the feature, it puts the branding back in place.. a great “rollback” option!)

Good luck .. and get Branding!!!