January 12, 2009

Sitefinity: Clean Up Search Results


You are using Sitefinity 3.x and your page templates and other non-desirable parts of the pages are showing up in search results.


Sitefinity spiders your site instead of searching the data. For the most part, this is a good thing, but it pollutes your search data.


Sitefinity gives us the tools to hide the template from the search spider, but they are rather hidden. To use this workaround, I am going to work under the assumption that all of your templates have a standardized naming scheme for their ContentPlaceHolder objects. For example, all of my pages have the main content in a ContentPlaceHolder named "Content," my sidebar is in a ContentPlaceHolder named "SideBarContent," and so on.

First, create a new master page that is empty except for the ContentPlaceHolder objects you want included in the search results and the header tag ContentPlaceHolder. Since I only want what is in my primary content area to appear in the search results, I have one ContentPlaceHolder in my body named "Content." Upload this into Sitefinity.

Second, if you do not have an App_Code folder in your Sitefinity project, add one to the project root.

Third, create a BasePage class. This class will inherit from InternalPage. Override the OnPreInit() function and drop in the following code...

if (CmsContext.IsCrawlerRequest)
this.MasterPageFile = "~/App_Master/SearchOverrideMasterPage.master";

...where SearchOverrideMasterPage.master is the name of the new master page you want to uploaded in step one.

Fourth, go into the Sitefinity folder and edit cmsentrypoint.aspx. Change...
...to be...
...where ClassNameOfBaseClass is the name of the class you created in Step 3.

Fifth, go into your App_Data/Search folder and delete the folders contained therein to delete the current search indices and results.

Finally, go into Sitefinity's Administration tab and under Services / Search, click "Start indexing" under each search index.

January 8, 2009

Sitefinity: Making a Custom Site Map

As part of a redesign of our current website at work, we're going to be changing to Sitefinity for our CMS.

The only downside is that working sans JavaScript is still a fairly big requirement for us and some of the built-in controls rely on JavaScript to function.

So...I'm rewriting some of the controls.

Here is a simple sitemap control that works with Sitefinity. Control is written in VB.NET, set up for CSS styling, and is free for customization as you see fit.

SiteMapControl.zip (1,150 bytes)