Nick Hadlee's Blog on SharePoint and Other Occasional Rants…


Intergen Blog: SharePoint 2013 Search
October 2, 2012, 8:33 pm
Filed under: 2013, Intergen, Search, SharePoint

I wrote a post over at the Intergen blog on SharePoint 2013 Search:

Search is an area of SharePoint that has been greatly improved with the forthcoming SharePoint 2013 release from Microsoft. The changes range from a new richer user interface through to a completely revamped back-end architecture…

Read more from this post at the Intergen Blog and while your at it have a look at the rest of our SharePoint 2013 series.



My Tech Ed NZ Session: What’s New in SharePoint 2013 Search?
September 15, 2012, 5:01 pm
Filed under: 2013, Search, SharePoint, Tech Ed | Tags: ,

I was luckily enough to attend and present at Tech Ed New Zealand again this year. My session was OSP206: What’s New in SharePoint 2013 Search?

It was a 200-250 level session to look at the changes from a few different perspectives:

  • The new UI
  • The new architecture
  • Administration changes
  • Developer changes
  • A demonstration of customising search results using Display Templates and Query Rules

I had a lot of fun attending and speaking at Tech Ed and really can’t wait for SharePoint 2013 to be released! Until then here are the slides from the session.



PowerShell and SharePoint Scripts from Tech.Ed NZ and Code Camp 2011
August 31, 2011, 9:59 pm
Filed under: 2010, Administration, PowerShell, Presentations

I recently did a PowerShell and SharePoint session at Tech Ed NZ 2011 and then again during Code Camp in the following weekend. The focus was on using PowerShell to create and configure a SharePoint portal and as promised here is a list of the scripts I used during my demo.  These scripts and a couple other useful files are in my SkyDrive so you can go and grab them individually. The whole lot is in the same place as a zip too.

This is the order that I showed and used them (or intended to):

  1. Add a managed account
  2. Add and configure a web application
  3. Add the managed metadata service application (Didn’t run this one just showed it)
  4. Adding site collections
  5. Configuring and adding content databases
  6. Backup and restore the farm, a service application and/or a web application (Didn’t run this one just showed it)
  7. Backup and restore a site collection
  8. Start a search crawl
  9. Add some sub sites
  10. Change the site collection properties to point to a search center
  11. Change the site properties to use alternate CSS and a site logo
  12. Adding users to the sites and adding a second site collection administrator
  13. Walkthrough of the web hierarchy (webs, lists, list templates, content types, fields)
  14. Basic deploy of solutions (WSP’s)
  15. A better way to deploy solutions
  16. Turning on the developer dashboard
  17. Checking the ULS

Note: These scripts were kept pretty simple to make them easy to read and describe during the demo. I’d strongly recommend you add a bit of error checking, maybe a few if/check statements etc before just running them willy nilly. Also some things were commented out during the sessions – uncomment them at your leisure.

Code Camp Slide Deck

The Code Camp slide deck is more or less the same as the Tech.Ed one.



No Search Results for Contextual Scopes
July 24, 2011, 12:22 pm
Filed under: 2010, Search, Troubleshooting

Contextual scopes are a really useful way of performing searches that are restricted to a specific site or list. The “This Site: [Site Name]”, “This List: [List Name]” are the dead giveaways for a contextual scope (I even think you can get a folder context too “This Folder” but it alludes me most of the time).  What’s better is contextual scopes are auto-magically created and managed by SharePoint for you so you should pretty much just use them in my opinion.

You may come across a problem where SharePoint search works fine except for your contextual scopes. Your global search scopes all return results but for some strange reason the contextual scopes are empty…

I came across this problem a couple of times recently and the fix is really pretty simple – check your alternate access mapping (AAM) settings and make sure the host header that is specified in your default zone is the same url you have used in your search content source. Normally SharePoint kindly creates the entry in the content source whenever you create a web application but if you have changed around any AAM settings and these two things don’t match then your contextual results will be empty. Case Closed!



Making Features that Deploy Content Types Compatible with the Content Type Hub
January 8, 2011, 10:55 am
Filed under: 2010, Content Types, Development, Tips & Tricks

* Update 15 May 2010 – this isn’t a problem! After some feedback from Chak’s and some retesting I’m happy to say that CAML features and the content type publishing hub work together fine. I can’t reproduce the problem and neither can Paul so I’m going to park this as a SharePoint X-File. I’d recommend you don’t use the method below unless you have a good reason to mix OM/CAML features in your deployment.

Paul Grimley wrote a post a while ago which highlighted a problem * with the content type publishing capability of SharePoint 2010. The particular problem highlighted by Paul’s post is the inability for content types to be published by the content type hub if they have been deployed by declarative CAML in a feature…seriously!

So we have two components of SharePoint 2010 – feature based content types and the content type hub – which are incompatible with each other. In my opinion there are lots of reasons you may want to deploy content types via features including:

  • Portability – deploying artefacts such as content types between environments such as DEVELOPMENT, UAT and PRODUCTION is much easier when they are wrapped up in a feature
  • Visual Studio 2010 support – you can leverage the content type SPI’s (SharePoint Project Item) for creating content types in your solution which provides a nice interface for selecting its parent etc etc
  • Readability – CAML based features are (sort of) human readable which sometimes makes it a lot easier to determine what is happening within the feature by reading the XML than the source code
  • Best Practice – haven’t we been told time and time again that it’s a best practice to deploy customisations to SharePoint via features and solutions?

So there are lots of reasons why we want to use features but we also want to use the content type hub, what are our options? After a bit of trial and error I came up with the following pattern that seems to work well albeit with a few limitations.

The Workaround

The API for 2010 provides a new constructor for the SPContentType class that lets us create a content type via the object model with a specified ID. This is a important change from the 2007 API which will be the basis of the workaround:

  • Create a base content type using the Object Model:
 string baseContentTypeId = "0x010100ee23a9df11631348b5a5ac7fdfd66b49";
SPContentTypeId contentTypeId = new SPContentTypeId(baseContentTypeId); SPContentType baseContentType = null;
baseContentType = contentTypes[contentTypeId];

if (baseContentType == null) {
	baseContentType = new SPContentType(contentTypeId, contentTypes, "Base Content Type Publishing");
	contentTypes.Add(baseContentType);
}
  • Any content types that should be publishable via the content type hub must be a descendant of this base content type (either a child, grand child etc)
<!-- Parent ContentType: Base Content Type Publishing (0x010100EE23A9DF11631348B5A5AC7FDFD66B49) -->
<contenttype id="0x010100EE23A9DF11631348B5A5AC7FDFD66B4900e54d81511bac4ad0837dd2ca3fb228e7" version="0" inherits="TRUE" description="A feature based Content Type that is publishable via the Content Type Hub" group="Custom Content Types" name="Base Document Content Type" />

My preference is to create the base content type via a ‘pre-requisite’ feature and then create a separate feature with the CAML based content types which will be dependent on this base content type feature. So far I’ve tested this ‘pattern’ with the following results:

  • These CAML based content types are disconnected from the features XML upon creation. This means any updates to the feature will not affect the content types. Updates to the published content types can be made by forcefully deactivating/reactivating the features but this is a risky operation as you might not know what has happened to the content types once they have been published.
  • If the attribute Overwrite=”TRUE” is included in either the content type or a field used by the content type the content type it won’t be published. It doesnt matter if the content type is a descendant of your base (publishable) content type or not it will never be published if you use the overwrite attribute.
  • These content types can be updated via the feature upgrade framework.

Unfortunately there are more than just a few things in SharePoint that you expect to work a certain way, or just work, that don’t. I love the platform but occasionally these “it almost works” moments can be pretty frustrating! If you have any feedback on this workaround I’d be keen to hear from you.



The First SharePoint Saturday New Zealand
December 19, 2010, 3:13 pm
Filed under: Development, jQuery, SharePoint, SharePoint Saturday, WCF

The first SharePoint Saturday was held in New Zealand on Saturday the 11th of December. I may be a little biased but I think the event was a real success with at least 80-100 people, close to 20 sessions and 17 speakers. A big thanks to all our sponsors, the speakers and also the other organisers. These events are a lot of work to put on so it wouldn’t have been possible without all of these people!

Any of the session slides that have been made available by the speakers are up on the site and we will continue to try and get the rest. Look forward to seeing everyone at next years event…

My session was in the developer stream and built a SharePoint 2010 Alerting solution to show how 1) to build a custom WCF web service that returns JSON, 2) how SP.UI JavaScript namespace is used to interact with the status bar, notifications and modal dialogues and 3) how to call web services from jQuery. The session slides are provide below for anyone that wants them:



An Alternative Method for Using Custom Master Pages with Search in SharePoint 2010
November 6, 2010, 3:41 pm
Filed under: 2010, Cutomisation, Development, Search

Search is a fundamental component of any SharePoint solution and 2010 has some subtle differences and great improvements over its 2007 predecessor:

  1. One improvement are refiners, a new part of the search user interface (formerly known as facets), which allow you refine the search results based on metadata and even better they are extensible
  2. One important difference between 2007 and 2010 is the use of a specific master page in the Search Centres – the minimal.master master page

I’m not a big fan of minimal.master used within the Enterprise Search Centre so that’s the focus of the rest of this post. I’ll propose a way to deliver a fix which basically boils down to not using the minimal.master.

So what’s the problem with minimal.master? Minimal.master is a cut down master page that is new to SharePoint 2010 and used by both Enterprise Search and Office Web Apps. As the Search master page it lacks a few key components available in the other SharePoint 2010 master pages. One fundamental component that is missing in minimal.master are navigation controls.

Minimal.master navigation

The minimal.master lacks most of the usual navigation controls you expect and need.

v4.master navigation

V4.master has the standard top navigation and the new 2010 breadcrumb (hidden inside the folder “up” icon)

Missing the main navigation leaves an Enterprise Search Centre completely isolated from the rest of your SharePoint solution. This is a big limitation – is there are any situation where you shouldn’t be able to get from your search results back to the main and/or other sites?

So why don’t we just change the search master page to one of those other fully featured ones like V4.master? Yeah that was my first idea too. And look what we get…

v4.master applied to search

An Enterprise Search Centre with v4.master applied “floats” the search controls into the breadcrumb navigation.

That wasn’t the result I was expecting and I guess it wasn’t the result most people were expecting if they tried this? This is not a bug but one of those “by design” problems. What you’re seeing is the way the four page layouts of Enterprise Search have been implemented to work specifically with the placeholders in the minimal.master master page. Personally I think this was a poor implementation decision because it uses some of the core placeholders completely differently than the other OOTB SharePoint master pages. Compare V4.master and minimal.master:

Place Holder Use in Minimal.master for search Use in V4.master for…most other things
TitleInBreadCrumb Search controls Breadcrumb navigation controls
SPNavigation Empty in the master page. The search page layouts add page editing controls and the ribbon instead. Page editing controls and the ribbon

The Current Approaches to using a Custom Master Page with Search

We have two options if we want to get rid of the minimal.master from search and put back some of the things we have lost:

  1. Create a custom search master page that is compatible with the search page layouts; or
  2. Modify the search page layouts to make them compatible with an existing custom master page

If you want to do the first option and create a custom master page for search then Randy Drisgill has a really useful and detailed post on how to convert a V4.master (normal) master page to work with the Search Centre.

The second alternative solution is to modify the page layouts to work with your existing custom master page. I first came across the idea via Chris O’Connor and prefer this approach. It’s biggest benefit is you only have to develop/test/maintain one master page which can be used on all your SharePoint sites including the search site!

Unfortunately there is at least one negative side effect to modifying the search page layouts – it makes them unghosted (customized). Unghosted files are generally frowned upon in SharePointland so this approach won’t always suit everyone’s environment/requirements. The biggest problem, and a very valid reason to dislike unghosted files, is once they are customized a copy lives in the content database that is disconnected from the original file system version. This means:

  • These page layouts will not be updated by any changes to the file system versions such as solution (wsp) upgrades and service packs
  • There is a performance penalty (I don’t know how much?) because of the extra database hit required to retrieve the page layout from the content database

Fix Option 2. Explained

There are a few changes that have to be made to all of the search page layouts and your custom master page to implement fix option number 2. To make this as clean as possible I have packaged the changes into a sandbox solution and use a site collection feature (feature activation receiver) to perform all of the heavy lifting in the page layouts:

  1. Change the target placeholder that is used by the search controls by replacing the Id from TitleInBreadCrumb to a custom placeholder ID CustomSearchControls
  2. Remove the SPNavigation placeholder and all its content from the page layouts. This content placeholder is in the v4 master page already so it’s just a duplicate and causes weird ribbon “jumping”
  3. Add some CSS style rules to hide the left navigation areas of the page because search doesn’t use this area of the page

A  big benefit of doing all that work in a feature receiver is the changes are all reverted and the page layouts are reghosted/uncustomized if the feature is deactivated.

Last point – there are changes that must be made to your custom master page to support these modified page layouts. If you don’t add the following placeholder you’ll get an error. The screen shot below shows what needs to be added (the wrapping <div> isn’t strictly necessary but it allows for any custom styling that might also be needed).

Custom PlaceHolder

And once you upload the sandbox solution to the solution gallery, activate the solution/feature and switch your master page to one with the custom placeholder this is what you will see:

Search with custom v4.master applied

This is a good place to stop. The files are up on codeplex and I hope to do a follow up post soon that explains the source code in detail. If you have any ideas on how to improve this or just general comments please hit me up via a blog comment or on twitter. For now here are links to the files:

  1. Sandbox solution with a site collection feature to do the page layout fix-up described in the post – Search.CustomMasterPageAdapter.wsp
  2. Source code of the feature receiver – PageLayoutFixup.cs
  3. Example custom master page which is just v4.master with the custom place holder added – Custom.v4.master



Follow

Get every new post delivered to your Inbox.

%d bloggers like this: