Archive

Archive for November, 2010

SharePoint Themes and how to make them work

November 11, 2010 Leave a comment

I’ll start at the end because I think I’m going to forget this the most often:

How to get a CSS file to be compiled by the theme engine

First of all, use the CssRegistration tag.  You’ll be happy you did when you don’t have to fight with SharePoint to get your CSS file to link properly.

 <SharePoint:CssRegistration Name="<%$SPurl:~SiteCollection/Style Library/en-us/Themable/MyHome.css%>" After="corev4.css" runat="server" />

The “<%$SPurl…” ensures that the url points to the current version (themed or non themed) of the css file.  Be sure to put this tag right after the SharePoint:CssLink tag, I’ve tried putting it in other places and for some unknown reason it breaks things pretty badly.

Place your CSS file under the themeable directory under the Style Library like the URL shown in the CssRegistration tag.

And now the secret sauce – CHECK IN AND PUBLISH YOUR CSS AND IMAGE FILES!

The theme engine will not pick up any non-published versions, you MUST check in your CSS and image files.

Finally, apply a theme – any old theme.

You’ll notice that when you apply the theme, and look at the page source your css files will have moved into a different directory:

 <link rel="stylesheet" type="text/css" href="/_catalogs/theme/Themed/9262B884/MyHome-4277C871.css?ctag=44">

Weird huh?

When you applied the style, the theme engine picked up all the style sheets and images and performed its magic on them.  Then it saved them to this separate location.

This means that any changes you now make to your original css or image files will not be reflected in your newly themed site – yes, that’s right, you need to go back and reapply your theme to the site so the theme engine will recompile the CSS and image files.  Man that’s annoying isn’t it?!

Using themes in your CSS files

Below are a list of the theme commands you can use in your CSS file.  The commands will replace CSS attributes or recolor images as appropriate if used properly.  But first, there’s a mysterious comment at the top of the corev4.css file that I’ve noticed:

/* _lcid=”1033″ _version=”14.0.4762″
_LocalBinding */

I don’t know what it does, and as far as I can tell, this page is the first reference to this comment anywhere on the interwebs.  For now I’ll leave this at the top, because it’s there in corev4.css and I want my style sheet to be just like corev4.css when it grows up.

Next – there are a few commands that can be used to theme-up your stylesheet:

ReplaceColor(themeColor) – should be put before a color attribute (obviously), this will replace the attribute color with a color from your theme.

ReplaceFont(themeFont) – this guy works like ReplaceColor, except with fonts.

RecolorImage(themeColor, method, includeRectangle) – should be put before an image reference – ie. url(<image url>).  This will color the image in the manner specified.  The only required parameter is the color, the other 2 params are optional:

themeColor – this one’s obvious, the color to use to re-color the image.
method – options here are: Filling, Blending, Tinting
includeRectangle – defines the section of the image to recolor i.e. {x:0,y:0,width:15,height:15} defines a rectangle starting at 0, 0 pixels, and is 15px high by 15px wide.

All of the above is pretty self-explanitory with the exception of the method parameter on the RecolorImage – for this, I refer you to an excellent blog post from Microsoft’s SharePoint team in which he shows examples of each recolor method, as well as all the permutations of the different colors.

One last thing – I’ve found themes to be not an extremely awful experience, just a painful one.  However, they can be useful every once in a while in limited situations.  For these limited situations it’s probably necessary to undo all the theming that’s in the corev4.css so that you can implement themes for only the elements that you wish.  The ThemeOverride.css stylesheet will override all the style rules in corev4.css, so that no theme colors or fonts will display.

To use the ThemeOverride.css stylesheet, just insert it between corev4.css and your custom css like so:

      <SharePoint:CssLink runat="server" Version="4" />
      <SharePoint:CssRegistration Name="<%$SPurl:~SiteCollection/Style Library/en-us/Themable/ThemeOverride.css%>" After="corev4.css" runat="server" />
      <SharePoint:CssRegistration Name="<%$SPurl:~SiteCollection/Style Library/en-us/Themable/MyHome.css%>"
           After="<%$SPurl:~SiteCollection/Style Library/en-us/Themable/ThemeOverride.css%>" runat="server" />

Be sure that you specify the ThemeOverride.css in the After attribute of your custom stylesheet.  Otherwise the ThemeOverride.css will be moved after your custom style sheet and will override all of your beautiful CSS work.

Advertisements
Categories: SharePoint, UI

The path specified cannot be used at this time. Exception from (HRESULT: 0x80070094)

November 8, 2010 2 comments

Recently, while attempting to deploy a new WSP file to my dev environment, I was presented with another exceptionally helpful error message:

Error: The path specified cannot be used at this time. Exception from (HRESULT: 0x80070094)

It took me a little bit to figure out, but basically, I reset the SP Timer service and all was well again.

What’s interesting is that even after getting this error, SharePoint claimed that the solution was properly deployed – though I didn’t want to take any chances with finding bugs due to a partially deployed solution.

Categories: Uncategorized