SharePoint Data View Part Magic and Search
This week has been busy with Tech Ready in town! Tech Ready is Microsoft's technical conference for the field. We host it twice a year. It's a great event because it provides an excellent forum for connecting with different people WW.
In any case, I thought I'd describe another sample I demonstrated in one of my sessions. I showed folks how easy it is to use SharePoint Designer to create some very rich, custom experiences. The scenario I showed was how you could use the Data View Web Part to connect to different search services – the SharePoint Search Web Service, Live.com search or any other search service that returns results via RSS or XML. The Data View Part is a no-code solution that allows you to very quickly connect to different data sources and display the search results and visually create the XSL you want. In fact, I know designers that use SPD to specifically help them create XSL.
For this sample, all you need is Windows SharePoint Services and SharePoint Designer. Here are the two things I recommend every SharePoint developer, IT Professional and Power User try out: Showing results from Live.com and Showing results from SharePoint search.
Showing results from Live.com
The end result of using a couple web parts in SPD is a simple form where someone can enter keywords and have formatted results returned.
Here is an outline of the steps:
1. Open up your site in SharePoint Designer.
2. Insert a Form Web Part (Insert -> SharePoint Controls -> Form Web Part)
3. Insert a Data View Part
4. In the Data Source Library section (on the right), expand Server-side Scripts and click on Connect to a script or RSS Feed…
5. Configure the source by entering the URL https://search.live.com/results.aspx and then adding the parameters q (with a default value of your choice; this is the parameter that specifies the keywords) and format with a default value of rss
6. Click on the down arrow next to the new data source and choose Show Data
7. Drag and drop the Title into any part of the page. You should see a list of search results. At this point, you can format the results the way you want. For example, you will probably want to make the title a hyperlink that links to the {link} parameter. You can style this visually and change the format of the HTML, add the description field, et cetera
8. At the top right of the web part, there is a little arrow where you can configure properties of the web part. Choose Web Part Connections. You want to take the value from the Form Web Part and connect it to the "q" variable that will be sent to search.live.com.
9. From the actions drop down, choose "Get Parameters From" and click Next.
10. Choose Connect to Web Part on this Page and on the next screen choose the Form Web Part
11. Match the T1 (or the variable you specified) to the q variable.
12. Now you're done! You've just implemented search on your WSS site!
Showing results from SharePoint Search
In order to show search results from SharePoint Search, you could take an approach exactly like the one above if you want to do simple keyword searches. For more complex queries, you can use the SharePoint Search Web Service. This time, for data source, you need to expand XML Web Service and click on Connect to a web service. For location, you should enter https://servername/_vti_bin/search.asmx. Click on Connect Now and you'll get a list of methods. Choose QueryEx from the dropdown. You can modify the queryXml variable to contain your query. For example, an example of a simple query is: <?xml version="1.0" encoding="utf-8" ?><QueryPacket xmlns="urn:Microsoft.Search.Query" Revision="1000"><Query domain="QDomain"><SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats><Context><QueryText language="en-US" type="STRING">arpans</QueryText></Context></Query></QueryPacket>
As you'll notice when you set the parameter, this can also be set through a web part connection. And now you are set! You can style the results visually and connect it to a Form Web Part to make it dynamic!
Comments
- Anonymous
July 29, 2007
PingBack from http://stevepietrekweblog.wordpress.com/2007/07/29/links-7292007/ - Anonymous
August 15, 2007
Después de unas semanas de vacaciones (cortas :PPP), aqui estamos de nuevo en el CIIN al pie del cañón - Anonymous
August 17, 2007
The Data View Part is a no-code solution that allows you to very quickly connect to different data sources - Anonymous
August 28, 2007
Arpan Shah has a nice post on his blog explaining how to use the DataFormWebPart to render search results - Anonymous
August 28, 2007
Arpan Shah has a nice post on his blog explaining how to use the DataFormWebPart to render search results - Anonymous
September 17, 2007
2007 MOSS Resource Links (Microsoft Office SharePoint Server) Here is an assortment of various 2007 Microsoft