Contextual Search Results Page Redirection via HTTPModule

So, I’m continuing my efforts at finding a way to handling Contextual Searching.

To describe the issue again, SharePoint allows you to search ‘This List’ or ‘This Site’. Unfortunately, these searches always show the ‘OSSSearchResults.aspx‘ results page, which is built into SharePoint, can’t be modified, and this means that you can’t use your normal ‘Search Center’ experience, which is usually modified and optimized for your users.

This is a shame, so I’ve been looking at ways of overcoming this problem. Continue reading “Contextual Search Results Page Redirection via HTTPModule”

Contextual Search Results Page Redirection via HTTPModule

Contextual Searching Via Search Box AppendQueryTerms

I’ve been looking at using the Search Box web part for a light-weight contextual search.

SharePoint allows you to search ‘This List’ or ‘This Site’. Unfortunately, these searches always show the ‘OSSSearchResults.aspx‘ results page, which is built into SharePoint, can’t be modified, and this means that you can’t use your normal ‘Search Center’ experience, which is usually modified and optimized for your users.

You can add a ‘context’ to a search with some of the search query terms. “Site:http://example/sites/docs” for example would restrict results to those below that URL. So, is there any way we can add that to our query? Continue reading “Contextual Searching Via Search Box AppendQueryTerms”

Contextual Searching Via Search Box AppendQueryTerms

Why I hate (and love) Site Definitions

I love the idea of site definitions. The idea that we can just say ‘give me a site for X’ and in a puff of magic smoke have a site with a feature rich experience just appear – that’s neat! And with SharePoint’s Feature mechanism and object model, we should be able to to a lot with them.

Strangely, after two and a half years working with SharePoint, I’d never built a site definition. (I don’t know how I managed that!) Recently, though, I’ve written several, and all I can say is that I’m older, and greyer than I was before. The reality of Site Definition development did not live up to my hopes. Continue reading “Why I hate (and love) Site Definitions”

Why I hate (and love) Site Definitions

ContentTypeRef vs ContentTypeBinding

Interesting question came up as a result of a post of Chris O’Briens:

Interesting you raise ContentTypeBinding. I use this in other areas (e.g. associating content types with Pages libraries). Don’t think it had occurred to me that I could use it here also.

Which kinda makes me wonder why the schema provides two ways of doing the same thing, but that could lead to whole ‘nother discussion 😉

Well, I get interested by questions like that. As far as I can tell…:

  • ContentTypeBinding elements exist in the Elements of a feature. They’re so that a feature can bind a new content type to a list
  • ContentTypeRef elements exist in the schema of a List definition (List > MetaData > ContentTypes > ContentTypeRef)

So, you can use the ContentTypeRef to create a list with a content type, or you can use a ContentTypeBinding to add it later. And you should be able to do it in the same feature – you could use a ListInstance to create a list using your definition, and then bind your content type. And yes, it does rather look like all three bits could be in the one Feature.

  1. List to define the list
  2. ListInstance to create one in your site
  3. ContentTypeBinding to add your content type.

I wonder what happens if you try to create a list definition without a content type reference? Might try that for a giggle sometime.

Side note: the Property element on a File element in a publishing site with the key PublishingAssociatedContentType is for associating the file (a page layout) with a page content type, not for associating the page content type to the Pages library. You have to do that as well, using a ContentTypeBinding element. (Thanks Waldeck, that was driving me nuts!)

ContentTypeRef vs ContentTypeBinding

Putting Custom Web Parts in ONET.xml

So yesterday I was trying to add a content editor webpart to a page I was deploying through ONET.XML. I wondered how to add custom web parts, and how you’d know what the XML for them was.

Turns out it isn’t very hard. An example:

<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="SourceCode.Solutions.GenericCaseWebParts.CaseSSRSReportViewer" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="TitleUrl" type="string" />
<property name="TitleIconImageUrl" type="string" />
<property name="ReportServerUrl" type="string">http://vm-moss:8088/ReportServer</property>
<property name="Parameters" type="string">&lt;ReportParameters&gt;&lt;Parameter Name="CaseId" MultiValue="false" Value="[Case Id]" /&gt;&lt;/ReportParameters&gt;</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="Title" type="string">Context Info</property>
<property name="ReportPath" type="string">/Reports/Case Details</property>
<!-- Snip -->
</properties>
</data>
</webPart>
</webParts>

As you can see, at the top we define the class to use, then we set various properties (I’ve trimmed that set quite a lot). But how did I get the XML? Well… I set the web part up in SharePoint and exported the web part to a file; this was the XML I needed to put into my ONET.xml. Copy and paste… job done.

Putting Custom Web Parts in ONET.xml

Putting CEWP into a page in ONET.XML

When you provision sites you can provide various pages (normal pages, not just publishing ones!) However, what if you want to put web parts onto those pages?

Well, you could build multiple pages for your different site configurations. Or you could use a feature receiver to add it programmatically. Or, you could add it via your site configuration. Continue reading “Putting CEWP into a page in ONET.XML”

Putting CEWP into a page in ONET.XML

Newsticker Web Part for SharePoint

I’ve written a web part that provides a ‘newsticker’ for SharePoint, although it’ll actually query for news, documents, or anything else you can query for with the Content Query Web Part (CQWP). In fact, it’s just a configuration of the CQWP, which also uses jQuery for animation and stuff. Typically web sites use this for displaying news or announcements, but you can use it to query for any SharePoint content type(s), as you would with the Content Query Web Part.

The Content Query Ticker Web Part looks like this in operation…

$(document).ready(function(){$(“#demoTicker”).cqticker(4000);});

  • Group 1 : Item A – Some Description
  • Group 1 : Item B – Some Other Description
  • Group 2 : Item C – Yet Another Description

It does require MOSS 2007, and you do need to enable the Publishing Infrastructure on your site collection.

For more details, see this page.

Newsticker Web Part for SharePoint

Putting actions into the PlaceHolderLeftActions

The Wiki and Blog sites have pages that make use of the PlaceHolderLeftActions content placeholder. I’ve mentioned this before regarding putting a web part zone below the quick launch menu. This time I wanted to list some actions for our ‘case’ system.

placeholderleftnavactions

The code to do this? Not very hard. Naturally, we’ll actually have some code to generate our actions and links…

<asp:Content ContentPlaceHolderId="PlaceHolderLeftActions" runat="server">
<DIV class="ms-quicklaunchouter">
<DIV class="ms-quickLaunch" style="WIDTH: 100%">
<DIV class="ms-quicklaunchheader">Case Actions</DIV>
<div>
<TABLE class="ms-navitem" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR><TD style="WIDTH: 100%">
<A class="ms-navitem" href="http://vm-moss/Default.aspx">Action 1</A>
</TD></TR></TABLE>
<TABLE class="ms-navitem" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR><TD style="WIDTH: 100%">
<A class="ms-navitem" href="http://vm-moss/Default.aspx">Action 2</A>
</TD></TR></TABLE>
</div>
</DIV>
</DIV>
</asp:Content>

Putting actions into the PlaceHolderLeftActions

Declaratively Point a Site Collection at a Search Center

Yesterday I wrote about the SmallSearchInputBox, how scopes only appear if you set a search center for the site collection, and how to set the Search Center in code.

Well, as is typically the way with CAML, I figured out how to do this declaratively later. Or, more specifically, I found that there is a feature I could call declaratively that would do what I want:

search-center-url-feature

<!-- SearchCenter Url feature -->
<Feature ID="7AC8CC56-D28E-41f5-AD04-D95109EB987A" >
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="SearchCenterUrl" Value="~SiteCollection/Search/" />
</Properties>
</Feature>

Yup, all I need to do is put that into my site definition…

Declaratively Point a Site Collection at a Search Center

Programmatically configure the Small Search Box to show scopes

Sharepoint’s ‘ordinary’ sites, such as Team Sites or Blank Sites, have a small search box (the SmallSearchInputBox) at the top which does not show search scopes, as we would be used to in a Collaboration Portal, for example…

search-blank-site-default

The reason for this is that they are not, by default, pointed at a particular Search Center – so they don’t have any idea what scopes to show. However, you can set this through the Site collection Search Settings…

search-site-collection-settings

And suddenly, your search scopes appear! Hurrah!

search-blank-site-now-with-scopespng

Now, what if we are creating a bunch of site collections? (Our current project could create quite a lot of site collections. And we need them created automatically, as required). Can we point them to a specific search center automatically? Continue reading “Programmatically configure the Small Search Box to show scopes”

Programmatically configure the Small Search Box to show scopes