Visual Best Bets in SharePoint 2010 without FAST

Using visual best bets is a very simple way to make your best bets stand out, if you don’t have Fast Server setup on your SharePoint environment this is not available out of the box. If you have FAST this is a good article on how to setup visual best bets.  For those of us without FAST here is how I did it.

To show best bests on the search results page you will either need to use a search center or create a custom search page and add the best bets web part to it. Here is what best bets look like out of the box.

SharePoint 2010 Visual Best Bets

Visual Best Bets without FAST

  1. Put the page in edit mode and then edit the best bets web part
  2. Click on the XSL Editor button
    SharePoint Edit XSl Button
  3. You can either or the little editor window or copy the code into an editor like Dreamweaver or Notepad
  4. On line 45 you will see this code
    <xsl:value-of select="Description"/>
  5. We are going to change the code to render the description field as HTML and not just plain text. Change the code on line 45 to this:
    <xsl:value-of disable-output-escaping="yes" select="Description"/>
  6. Save the changes to the web part and save the page.
  7. Now we need to setup our best bets to show images. If you dont already have best bets setup you can follow the steps outlined here
  8. Once you have a best bet setup edit it and in the description use HTML to show the image you want to display.
    <img src="URLofImage" alt="description of image"/>

    SharePoint 2010 search best bets setup

  9. Save the best bet and run a test search.

SharePoint 2010 Search best bets with images and no FAST

Visual best bets not only look better than the other results but can allow you to show more detailed information about the result without them having to click. Using this same solution you could include other HTML to show multiple image, the top pages from a site or other information useful to the person searching.

Read More

Simple SharePoint Search Box with Radio Buttons

So lets say you want users to be able to selectively search content from 3 (or more) different lists (The lists may or may not be on the same site). Out of the Box there is not an easy way to do this.

  • Having the user browse to each list or library and search it specifically
  • Use the site wide search which will return results from the whole site.

You could setup search scopes for each list but if you manage a large number of sites this could become a lot of work to maintain.

So the plan is to build one search box with radio buttons that will let you choose what list or scope you want to query.  Here is how I did it.  (more…)

Read More

Adding Suggestions to the Sharepoint search box : Part 2

In Part 1 of this post we used a simple javascript to display suggestions on a custom search box. After I wrote that post I was thinking it would make more sense to read the suggestions from a list instead of a JavaScript file. This post will explain how to setup the list and edit the JavaScript to read the suggestions from a list. The idea is that an administrator could manage the list and help guide users toward specific information instead of getting numerous un-related results like in those commercials for bing.

Assuming you already have the search box setup as described in Part one of this post all you will need to do is change the javascript and add some code to the page. (more…)

Read More

Filter Lists by Date Range

On a recent project one of the requirements was that users be able to filter a list by a date range.  To this I tried using two date filter webparts connected to a data view webpart.  A detailed description of how to set this up can be found here.  This solution worked well enough but there was a page refresh after the user entered each date, so the user enters the first date (page refresh) user enters second date (page refresh again) and finally they get the results.  This annoyed me, I wanted to remove the extra page loads so I tried several things and this is what I finally came up with.

Setup

Using a content editor webpart build the form elements needed to collect the dates, two inputs and a search button.  Give each input a unique ID. Here is the code I used.

<script language="JavaScript">
function submitForm()
{
var startDate = document.getElementById('startDate').value;
var endDate = document.getElementById('endDate').value;
window.parent.location="default.aspx?T1=" + startDate + '&T2=' + endDate;
}
</script>
<p><div id="dateDiv" style="display:none;" class="filterBox">
<h4>Date Search</h4>
        Between
<input name="startDate" type="text" id="startDate" value="" size="15" class="dateformat-Y-ds-m-ds-d" value="">
and
<input name="endDate" type="text" id="endDate" value="" size="15" class="dateformat-Y-ds-m-ds-d" value="">
 YYYY-MM-DD
<input type="submit" name="Submit" value="Go"  onClick="submitForm();this.disabled=true;">
</div>

The class names are used to activate the date picker script but can be whatever you want. I used this date picker script from Frequecy Decoder

The submitForm() function simply takes the values from the inputs and adds them as query string variables at the end of the URL. We can now use these values to filter the list.

Filtering the Data View Web part

To filter the content of the DVWP based on the date we have to setup some parameters for the start and end dates.   Under ‘Common Data View Tasks’ just choose ‘Parameters’ for both the start and end date set the source as ‘Query String’. The query string variable will be whatever you defined in the JavaScript so in this case they are T1 and T2. Set the default value for the start date to some date impossibly far in the past and for the end date set it to something like the year 3000. This will ensure that the list will show all records if no values are passed for the start and end dates.

parameters

Then all you have to do is setup your filter based on the parameters from the query string.

filter

You’re done.

Things to remember

The date has to be passed in YYYY-MM-DD format in order to work.

If the detault values for your start and end date parameters are not set high / low enough all records will not display when not date range is entered.

Read More

Adding Suggestions to the Sharepoint search box

Search Suggestions

I got the idea for this from here: http://cssglobe.com/lab/searchfield/. The idea is that by giving users suggestions of what they should be searching for they can be guided to the most important information. When I am searching for something many times I am unsure what what search terms will give me the best results.

To get started we will need a search box to work with.  The out of the box search box could work but I prefer to use the one mentioned here by Kyle Schaeffer because it gives me a lot more flexibility with the design.    (more…)

Read More