Creating Site Templates

Note that Site Templates aren’t the same as Site Definitions. Good article about how to do this here. Or read Creating a Custom SharePoint 2007 Portal Site Definition using the PortalProvisioningProvider Class for ‘portals’ (I agree – that’s the most over-used word in SharePoint, along with confuse over what a ‘site’ is (sometimes a collection, sometimes just a site…)).

It’s worth considering the differences between (more here). Some of the differences demystified (note – about Beta 2). Info on how to create a custom site definition (hint – copy an existing one – bit more here). And information on which existing templates are right for me.

Creating Site Templates

Get around workflow version issues – and better ways to start workflows

Workflow versioning in SharePoint by Daniel Herzog. Yeah, it’s a problem that I’ve been wondering about, and his suggestions are valid. I was interested by the link to Start workflows from the context menu – to me, this is a much more natural place to start a workflow from.

Found from Julie’s Blog

Get around workflow version issues – and better ways to start workflows

Excelllent – A CAML query generating library

To those of you who’ve never written a CAML query, this won’t seem exciting. For those of you have have spent hours digging through reams of XML searching for a fault in your query, this will be heaven sent:

CAML.NET assembly – write your queries in C# – and you can find it on Codeplex.

Queries are now as simple as:
string s = CAML.Query(
CAML.Where(
CAML.Eg(
CAML.FieldRef("SomeField"),
CAML.Value(someValue)
)
)
)

This is such a blatantly good idea that I’m giving it a

Comments from my old blog:

 

Now that *is* a good idea…

By Jonathan at 17:11:14 Sunday 13th May 2007

Excelllent – A CAML query generating library

MOSS, themes and master pages

So, Joel Oleson has blogged a bit about master pages and themes in MOSS. This is an area I think that the SharePoint team have the right idea, but execution is a little short.

My problems are that we have master pages – which is great. And we’ve got seperate master pages for standard pages, and administration pages. Okay, I’m happy with that. However, there is a mechanism for changing the master page for normal pages – but nothing for administration pages. ‘Cos nobody will ever look at them, right?

Then there is the question of master pages and themes. I really like some of the themes that come OOB, much more so than the default ‘blue’ (I like ‘Simple’). But they can only be applied on a site by site basis; there is no inheritance mechanism. And if you use a master page, it’ll probably override the theme anyway. So why have themes? Why not just use master pages?

MOSS, themes and master pages

Content Query Web Parts and Site Categories

Here’s a thought – wouldn’t it be cool to have a way of getting content from Sites in a Site Collection, but filtered by their category data?

At the moment, the Content Query Web Part gives you 3 options as to what sites it queries:

  1. A specific site
  2. This site and its children
  3. All sites in the collection

Wouldn’t it be great, though, to form that list of target sites based on a category? For example, in a big company it may have a number of divisions, each with their own ‘Finance’ department. A content query web part that could show content from all the ‘Finance’ category sites across the organisation would be very cool.

Can’t see a way of doing it at the moment though. I suppose I could write my own web-part – but the Content Query Web Part gives you so much already, I don’t want to have to replicate that.

Content Query Web Parts and Site Categories

Master Pages for Admin and global pages

One of the pains about master pages in SharePoint is that when you set one for a site, it doesn’t apply to the admin pages. This can lead to a, um, interesting difference in appearance.

I started looking into overcoming this. Obviously, there is a fairly straight-forward approach – modify the application.master. Ouch. Then, any changes to design in one file have to be replicated elsewhere, with one file in the Master Page Gallery, and one on the file system.

Alternatively, I found a neat solution at David’s blog. This uses an HTTP Module to reset the master page for any pages looking for application.master.

But after following his instructions, my admin pages wouldn’t work. I just got the error page ‘Unknown Error’.

Digging into the logs, I found what was going on – there were 2 content placeholders that the application.master uses which weren’t on my ‘normal’ master page. Make sure you add place holders for:

<asp:ContentPlaceHolder id="PlaceHolderPageDescriptionRowAttr" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageDescriptionRowAttr2" runat="server"/>

The full list of placeholders used in both files is:

  • PlaceHolderPageTitle
  • PlaceHolderAdditionalPageHead
  • PlaceHolderBodyAreaClass
  • PlaceHolderBodyLeftBorder
  • PlaceHolderBodyRightMargin
  • PlaceHolderCalendarNavigator
  • PlaceHolderFormDigest
  • PlaceHolderGlobalNavigation
  • PlaceHolderGlobalNavigationSiteMap
  • PlaceHolderLeftActions
  • PlaceHolderLeftNavBar
  • PlaceHolderLeftNavBarBorder
  • PlaceHolderLeftNavBarDataSource
  • PlaceHolderLeftNavBarTop
  • PlaceHolderMain
  • PlaceHolderMiniConsole
  • PlaceHolderNavSpacer
  • PlaceHolderPageDescription
  • PlaceHolderPageImage
  • PlaceHolderPageTitleInTitleArea
  • PlaceHolderSearchArea
  • PlaceHolderSiteName
  • PlaceHolderTitleAreaClass
  • PlaceHolderTitleAreaSeparator
  • PlaceHolderTitleBreadcrumb
  • PlaceHolderTitleLeftBorder
  • PlaceHolderTitleRightMargin
  • PlaceHolderTopNavBar
  • PlaceHolderUtilityContent
  • SPNavigation
  • WSSDesignConsole
  • PlaceHolderHorizontalNav Normal master page only
  • PlaceHolderPageDescriptionRowAttr Admin master page only
  • PlaceHolderPageDescriptionRowAttr2 Admin master page only
Master Pages for Admin and global pages

The format of Dates in CAML

So, a colleague asked me about what format dates should be put into the where clause of a CAML query as. I’d had a lot of problems finding this out myself, and ultimately I found that a .ToString(“u”) on a DateTime object did the trick. The produces a time of the form 2006-04-17 21:29:09Z

For example, using a StringBuilder to create my CAML query (for my SPQuery object), this might look like:

caml.Append("<Leq>");
caml.Append("<FieldRef Name='MyDueDate'/>");
caml.Append("<Value Type='DateTime'>");
caml.Append(System.DateTime.Today.ToString("u"));
caml.Append("</Value>");
caml.Append("</Leq>");

(This query contains the date contained in the MyDueDate column with the current date and time).

The format of Dates in CAML