March 29, 2007

The system cannot find the file specified. (0x80070002) in Event Log

If your search in Wss 3.0 site returns no results when it should have, check the event log for the error The system cannot find the file specified. (0x80070002). It may be the indication of your windows search service not running. Start it and check if it is ok.

March 20, 2007

Weird behaviour with custom search box control

While i was trying some formatting on the custom search box control that I mentioned in my Customizing wss 3.0 default search scope post I encountered a weird behaviour. I simply issued a format(code beautfy ctrl K-D) command and saved the control , and this made the control invisible on my sharepoint main site. I didn't guess it was because of my command and wrestled with stsadms, reinstall features etc. When I returned back from a backup I was surprised (and happy!) to see it working again.

March 15, 2007

Customizing search results page appearance in WSS 3.0

In this post I will share two tips about the customization of sharepoint search results appearance.
The results page is located in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\searchresults.aspx". This is the page we will change.
First of all suppose we want to show 5 results page instead of the default 10. Open the aspx page and edit the SearchWC:CoreResultsWebPart.... webpart attributes by adding ResultsPerPage='"5". This should be enough.
As you may have noticed CoreResultsWebPart is a class showing results. Rather than duelling with the Reflector and writing my own class, handling the searches, the followng part was easier and much quicker for me. Secondly, what I wanted to accomplish was to remove the author and date information from the results pages. This was somewhat harder than the first part :). For this I have added another attribute to
SearchWC:CoreResultsWebPart, that is OnPreRender="PreRender_Handler".
Than add the following snippet



public void PreRender_Handler(object sender, System.EventArgs e)
{
CoreResultsWebPart coreResults = (CoreResultsWebPart)sender;
string searchResultsTxt = ((Literal)(coreResults.Controls[0])).Text;
Regex rex = new Regex(@"^\s*-\s*^\s*(\w*)\s*^\s*-\s*^\s*(\d+/\d+/\d+)",
RegexOptions.Multiline);
string replaced = rex.Replace(searchResultsTxt, string.Empty);
((Literal)(coreResults.Controls[0])).Text = replaced;

}



This code gets the search results html page and parses it with a regular expression , for cleaning the htmls of author and publishing date information. The Literal is the container for the html results. The regular expression gets the name and date in groups in case you may want to use them.
Hope it helps...

Customizing wss 3.0 default search scope

In Moss 2007 , you can define custom search scopes from administration application. However, AFAIK, there is no such support for wss 3.0.

As you may know in wss 3.0 your searches are limited to site and its subsites. That is, ff you are in the context of a subsite, your search can not contain items from its parent.
But, for a project, I wanted to enable site-wide search that is all searches will begin from the root site.To enable this behaviour i have followed the steps in
How to: Customize a Delegate Control. After making sure it has worked as expected, I customized the custom control located in "controltemplates" directory. This process consisted of finding the root web site and setting it as the search scope.
Here is the code:
<% string strScopeWeb = null; string strScopeList = null; string strWebSelected = null; /*-----find the root website -----------*/ SPWeb rootweb= null; foreach (SPWeb spweb in SPContext.Current.Site.AllWebs) { if (spweb.IsRootWeb) { rootweb = spweb; break; } } /*----------------*/ SPWeb web = SPControl.GetContextWeb(Context); string strEncodedUrl = SPHttpUtility.EcmaScriptStringLiteralEncode( SPHttpUtility.UrlPathEncode(web.Url + "/_layouts/searchresults.aspx", false, false) ); strEncodedUrl = "'" + strEncodedUrl + "'"; //following line is commented for the search to include root web site //strScopeWeb = "'" + SPHttpUtility.HtmlEncode( web.Url ) + "'"; strScopeWeb = "'" + SPHttpUtility.HtmlEncode(rootweb.Url) + "'"; SPList list = SPContext.Current.List; if ( list != null && ((list.BaseTemplate != SPListTemplateType.DocumentLibrary && list.BaseTemplate != SPListTemplateType.WebPageLibrary) || (SPContext.Current.ListItem == null) || (SPContext.Current.ListItem.ParentList == null) || (SPContext.Current.ListItem.ParentList != list)) ) { strScopeList = list.ID.ToString(); } else { strWebSelected = "SELECTED"; } %>
That's it. You don't need to install the feature again.
Enjoy.

March 14, 2007

Finding root web site

/*-----find the root website to -----------*/
SPWeb rootweb= null;
foreach (SPWeb spweb in SPContext.Current.Site.AllWebs) //this returns all sites in the site
// collection
{
if (spweb.IsRootWeb)
{
rootweb = spweb;
break;
}
}

March 07, 2007

Sharepoint Designer Videos are available

Here are the first series of videos for using Sharepoint Designer 2007.

http://office.microsoft.com/en-us/help/HA102199841033.aspx
Failed to activate feature {GUID} at scope {sitename}

When I created a new web application at a custom port in WSS 3.0, the features on my old web site are NOT activated automatically.
But the features are listed anyway. When you try to activate them from site actions -> site collection features you got this error message:
Failed to activate feature {GUID} at scope {sitename}.
What you should do is to add the dll's of your features to your safecontrols list in your web.config file located in your site root. (namely c:inetpubwwwrootwss{portnumber})
You can copy them from your current site.

March 01, 2007

VMWARE Converter

As you may have noticed, the price fall in cpus, rams and disks made virtualization a hot topic in the IT industry, and I got my share too :).
We have been developing our sharepoint project on a virtual server where two developers remotely connect and use visual studio.
I have been evaluating vmware and virtual server of Microsoft.
Last night while I was browsing I have noticed a free product of vmware , namely Vmware Converter. This beast just takes your physical installed machine
and makes a virtual machine of it. And to my surprise it WORKS! . You might give it a try.
Check it out here.