<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dave Cavins &#187; suggestions</title>
	<atom:link href="http://davecavins.com/tag/suggestions/feed/" rel="self" type="application/rss+xml" />
	<link>http://davecavins.com</link>
	<description>web design, SharePoint customization &#38; random stuff</description>
	<lastBuildDate>Tue, 31 Aug 2010 18:01:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adding Suggestions to the Sharepoint search box : Part 2</title>
		<link>http://davecavins.com/2009/10/suggestions-foto-the-sharepoint-search-box-part-2/</link>
		<comments>http://davecavins.com/2009/10/suggestions-foto-the-sharepoint-search-box-part-2/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 16:07:37 +0000</pubDate>
		<dc:creator>davecavins</dc:creator>
				<category><![CDATA[General SharePoint]]></category>
		<category><![CDATA[SharePoint Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[suggestions]]></category>

		<guid isPermaLink="false">http://davecavins.com/?p=233</guid>
		<description><![CDATA[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 [...]


Related posts:<ol><li><a href='http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/' rel='bookmark' title='Permanent Link: Adding Suggestions to the Sharepoint search box'>Adding Suggestions to the Sharepoint search box</a></li>
<li><a href='http://davecavins.com/2009/11/sharepoint-vertical-news-ticker/' rel='bookmark' title='Permanent Link: SharePoint Vertical News Ticker'>SharePoint Vertical News Ticker</a></li>
<li><a href='http://davecavins.com/2009/11/slideshow-with-captions/' rel='bookmark' title='Permanent Link: Image Slideshow with captions'>Image Slideshow with captions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/">In Part 1 of this post</a> 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 <a href="http://www.youtube.com/watch?v=i1AwFY6MuwE" target="_blank">those commercials for bing</a>.</p>
<p>Assuming you already have the search box setup as described in <a href="http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/">Part one of this post</a> all you will need to do is change the javascript and add some code to the page.</p>
<h2>Setup</h2>
<ul>
<li>Do everything from the first post</li>
<li>Add a link to jQuery somewhere on the page.</li>
<li>Create a custom list called &#8216;Suggestions&#8217;. It just needs to have the default title field. Create at least one item in the list and in the title enter several comma separated words.</li>
<li>Add the code below to the page.</li>
</ul>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript” src=“http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js”&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function GetItemsFromSP() {
    var soapEnv =
 “&lt;soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'&gt; \
                &lt;soapenv:Body&gt; \
                     &lt;GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'&gt; \
                        &lt;listName&gt;Suggestions&lt;/listName&gt; \
                        &lt;viewFields&gt; \
                            &lt;ViewFields&gt; \
                               &lt;FieldRef Name='Title' /&gt; \
                           &lt;/ViewFields&gt; \
                        &lt;/viewFields&gt; \
                    &lt;/GetListItems&gt; \
                &lt;/soapenv:Body&gt; \
            &lt;/soapenv:Envelope&gt;”;
       $.ajax({
        url: “_vti_bin/lists.asmx”,
        type: “POST”,
        dataType: “xml”,
        data: soapEnv,
        complete: processResult,
        contentType: “text/xml; charset=\”utf-8\”“,
        async: false
    });
}
function processResult(xData, status) {
    $(xData.responseXML).find(“z\\:row”).each(function() {
        $(“#data”).append(“” + $(this).attr(“ows_Title”) + “,”);
    });
}
&lt;/script&gt;
&lt;script type=“text/javascript” src=“Resources/searchfield.js”&gt;&lt;/script&gt;
&lt;div style=“display:none; visibility:hidden” id=“data”&gt;&lt;/div&gt;
</pre>
<p>The code above get the items from the Suggestions list, seperates them with commas and puts them in a hidden div with an ID of data. Now we just need to edit the searchfield script to read in the information from our hidden div. To do this edit searchfield.js line 26 to call the GetItemsFromSP function and set the suggestionText variable to be equal to the contents of our hidden div. Here is the code.</p>
<pre class="brush: jscript;">
/**/*/*/*/**/
	GetItemsFromSP();
	var suggestionText =  $(“#data”).html();
</pre>
<p>Test the page and make sure it works by typing the first few letters of one of the words in you list item.</p>
<h2>Conclusion</h2>
<p>This is very similar to <a href="http://weblogs.asp.net/jan/archive/2009/07/02/sharepoint-search-as-you-type-with-jquery.aspx">Jan Tielens&#8217; SharePoint Search-as-You-Type with jQuery solution </a>but I wanted the search box to still be usable even if there are no suggestions. In Jan&#8217;s solution the &#8216;search box&#8217; does not actually do anything when the magnifying glass is clicked. There are likely better ways to do this and if you know of one please post a comment.</p>


<p>Related posts:<ol><li><a href='http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/' rel='bookmark' title='Permanent Link: Adding Suggestions to the Sharepoint search box'>Adding Suggestions to the Sharepoint search box</a></li>
<li><a href='http://davecavins.com/2009/11/sharepoint-vertical-news-ticker/' rel='bookmark' title='Permanent Link: SharePoint Vertical News Ticker'>SharePoint Vertical News Ticker</a></li>
<li><a href='http://davecavins.com/2009/11/slideshow-with-captions/' rel='bookmark' title='Permanent Link: Image Slideshow with captions'>Image Slideshow with captions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://davecavins.com/2009/10/suggestions-foto-the-sharepoint-search-box-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Suggestions to the Sharepoint search box</title>
		<link>http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/</link>
		<comments>http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 20:10:41 +0000</pubDate>
		<dc:creator>davecavins</dc:creator>
				<category><![CDATA[SharePoint Design]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint Designer]]></category>
		<category><![CDATA[suggestions]]></category>

		<guid isPermaLink="false">http://davecavins.com/?p=46</guid>
		<description><![CDATA[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 [...]


Related posts:<ol><li><a href='http://davecavins.com/2009/10/suggestions-foto-the-sharepoint-search-box-part-2/' rel='bookmark' title='Permanent Link: Adding Suggestions to the Sharepoint search box : Part 2'>Adding Suggestions to the Sharepoint search box : Part 2</a></li>
<li><a href='http://davecavins.com/2009/02/adding-stuff-to-the-page-head-the-easy-way/' rel='bookmark' title='Permanent Link: Adding references to the page head: the easy way'>Adding references to the page head: the easy way</a></li>
<li><a href='http://davecavins.com/2010/08/a-better-annoucements-ticker/' rel='bookmark' title='Permanent Link: A Better Annoucements Ticker'>A Better Annoucements Ticker</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-70 alignright" title="search" src="http://davecavins.com/wp-content/uploads/2009/04/search.jpg" alt="Search Suggestions" width="243" height="152" /></p>
<p>I got the idea for this from here: <a href="http://cssglobe.com/lab/searchfield/" target="_blank">http://cssglobe.com/lab/searchfield/</a>. 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.</p>
<p>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 <a href="http://www.thesug.org/Blogs/kyles/archive/2008/2/11/Design_Minute_SharePoint_Search_Box.aspx.aspx" target="_blank">here by Kyle Schaeffer</a> because it gives me a lot more flexibility with the design.   <span id="more-46"></span></p>
<h3>Adding a Search Box to the page</h3>
<p>To get the search box on your page :</p>
<ol>
<li>Add this register tag at the top of the page layout or masterpage :
<pre class="brush: plain;">
&lt;%@ Register Tagprefix=&quot;SPSWC&quot;
Namespace=&quot;Microsoft.SharePoint.Portal.WebControls&quot;
Assembly=&quot;Microsoft.SharePoint.Portal, Version=12.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;</pre>
</li>
<li>If needed hide the existing search box (I left mine, and it still works fine).</li>
<li>Put this code where you want the search box to show up:
<pre class="brush: plain;">&lt;br /&gt;
&lt;div id=&quot;searchLayout&quot;&gt;
&lt;SPSWC:SearchBoxEx id=&quot;SearchBox&quot; RegisterStyles=&quot;false&quot; TextBeforeTextBox=&quot;&quot; TextBoxWidth=&quot;200&quot; GoImageUrl=&quot;&quot; GoImageActiveUrl=&quot;&quot; GoImageUrlRTL=&quot;&quot; GoImageActiveUrlRTL=&quot;&quot; UseSiteDefaults=&quot;true&quot; DropDownMode=&quot;HideScopeDD&quot; SuppressWebPartChrome=&quot;true&quot; runat=&quot;server&quot; WebPart=&quot;true&quot; __WebPartId=&quot;{0043945F-2D2B-4A02-8510-CED13B6F04DF}&quot;&gt;
&lt;/div&gt;
&lt;p&gt; </pre>
</li>
<li>Save the page.</li>
</ol>
<h3>Javascript</h3>
<p>Ok now comes the integration part.  In the JavaScript code searchfield.js you must insert the ID of the search input field.</p>
<p>
<pre class="brush: jscript;">var id = &quot;searchfield&quot;</pre>
</p>
<p>In ASP.NET control IDs change when the page is rendered so the best way to do this is to view the source of the page or use FireBug to get the id.  It will be something long like &#8220;ctl00_PlaceHolderMain_searchbox2_SFF4064A0_InputKeywords&#8221;</p>
<p>Now save the JS file and test the page.</p>
<p>If it does not work make sure you have referenced your javascript properly.</p>
<ul>
<li>If you are doing this in a page layout the script link should go inside the AdditionalPageHead content place holder.</li>
<li><span class="asp">If you are putting this in a masterpage you can either refernece the script in the &lt;head&gt; section or just above the closing &lt;/body&gt; tag.</span></li>
</ul>
<div id="attachment_151" class="wp-caption aligncenter" style="width: 229px"><a href="http://davecavins.com/wp-content/uploads/2009/04/search2.jpg"><img class="size-full wp-image-151" title="search2" src="http://davecavins.com/wp-content/uploads/2009/04/search2.jpg" alt="Search Suggestions" width="219" height="200" /></a><p class="wp-caption-text">Search Suggestions</p></div>
<h3>Watch out</h3>
<p>This script includes code that will clear the contents of the search box on the first focus so you don&#8217;t need to use the &#8220;QueryPromptString&#8221; tag on your search box because it wont work.</p>
<p>This is what mine came out looking like with a little CSS code.  Also to get the &#8220;Go&#8221; image to show up I just set the &#8220;GoImageUrl&#8221; attribute.</p>
<h3>Conclusion</h3>
<p>This is a very simple solution and can help enhance the user experience but it is not as integrated with SharePoint as I would like.  Ideally the suggestions would be read in from a list stored somewhere on the site.</p>


<p>Related posts:<ol><li><a href='http://davecavins.com/2009/10/suggestions-foto-the-sharepoint-search-box-part-2/' rel='bookmark' title='Permanent Link: Adding Suggestions to the Sharepoint search box : Part 2'>Adding Suggestions to the Sharepoint search box : Part 2</a></li>
<li><a href='http://davecavins.com/2009/02/adding-stuff-to-the-page-head-the-easy-way/' rel='bookmark' title='Permanent Link: Adding references to the page head: the easy way'>Adding references to the page head: the easy way</a></li>
<li><a href='http://davecavins.com/2010/08/a-better-annoucements-ticker/' rel='bookmark' title='Permanent Link: A Better Annoucements Ticker'>A Better Annoucements Ticker</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://davecavins.com/2009/04/adding-suggestiong-to-the-sharepoint-search-box/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
