Skip to main content
Email Password   helpLost your password?
Screenshot - sample.gif

Introduction

For use in Microsoft Office SharePoint Server (MOSS) 2007, this Web Part displays the site structure in a hierarchical tree that is expandable and collapsible. It is based on my Site Map custom control written for Content Management Server 2002.

Description

The Web Part uses a PortalSiteMapProvider to render the site structure in a hierarchical tree that is expandable and collapsible. The PortalSiteMapProvider is referenced from the site's web.config and is defaulted to be CurrentNavSiteMapProvider, as used in the out-of-the-box "Current Navigation".

It has several public properties:

The Web Part uses two methods to include resources. Images are treated as Class Resources and JavaScript files are treated as Embedded Resources. To package images as Class Resources in a Solution, include them in Manifest.xml, like:

<?xml version="1.0" encoding="utf-8" ?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/"
    SolutionId="SolutionGuid" ResetWebServer="TRUE">
    <Assemblies>
        <Assembly Location="QuestechSystems.SharePoint.Publishing.SiteMap.dll"
            DeploymentTarget="GlobalAssemblyCache">
            <ClassResources>
                <ClassResource Location="images\node-closed.gif" />
                <ClassResource Location="images\node-open.gif" />
                <ClassResource Location="images\node.gif" />
            </ClassResources>
            <SafeControls>
                <SafeControl Assembly="QuestechSystems.SharePoint.Publishing.SiteMap,
                    Version=1.0.0.0,
                    Culture=neutral, PublicKeyToken=AssemblyToken"
                    Namespace=
                    "QuestechSystems.SharePoint.Publishing.WebControls"
                    TypeName="*" Safe="True" />
            </SafeControls>
        </Assembly>
    </Assemblies>
    <FeatureManifests>
        <FeatureManifest Location="QuestechSiteMapWebPart\Feature.xml" />
    </FeatureManifests>
</Solution>

In Solution deployment, resource files are deployed based on the assembly destination. For assemblies deployed to the bin directory, resource files are copied to an assembly subdirectory under the wpresources directory of the destination IIS Web application. For assemblies deployed to GAC, resource files are copied to an assembly subdirectory under virtual directory _wpresources. In the code, a path to resource files is obtained from SPWebPartManager.GetClassResourcePath.

For the JavaScript file SiteMap.js, set its build action to "Embedded Resource" in Visual Studio 2008. In code, reference the file using Page.ClientScript.GetWebResourceUrl. You will need to pass in the file in the form of [Assembly of project].[Folder containing resource].[Filename of resource]. In AssemblyInfo.cs, include SiteMap.js in the same format like:

[assembly: System.Web.UI.WebResource
    ("QuestechSystems.SharePoint.Publishing.ClientScripts.
    SiteMap.js", "text/javascript")]

The Web Part also uses a resource file to store all messages and property attribute UI strings. It demonstrates how to develop a custom class that inherits WebDescriptionAttribute, WebDisplayNameAttribute or CategoryAttribute and returns a localized string from your own Resource Manager.

The sample Visual Studio 2008 solution includes all the support files you need to build and deploy this Web Part, minus strong name key files (*.snk). It contains three projects: Deployment, Features and SharePoint.Publishing. The SharePoint.Publishing project contains source codes for the Web Part. The Features project contains all the features to support the SharePoint.Publishing project. The Deployment project contains a pre-build script to aggregate all the files needed for deployment. It contains a Solution directory where a WSP file is generated and deployed by a post-build script.

This structure of Visual Studio solution and projects is scalable to full blown MOSS/WSS development and deployment. You could add additional projects like SharePoint for WSS or MOSS non-publishing development or SharePoint.ApplicationPages for customization of administrative layout pages. Within your projects, you could have other custom components like user and Web controls, custom fields, feature receivers, etc.

Installation

Using stsadm, install solution file QuestechSiteMap.wsp in \Deployments\Solution\:

stsadm -o addsolution -filename QuestechSiteMap.wsp

Go to SharePoint Central Administration/Operations/Global Configuration-Solution Management. Deploy the installed solution to selected Web applications. In the site collection where the solution is deployed, activate Feature Questech Systems Site Map Web Part. After that, the Site Map Web Part should be available for you to add to pages.

References

  1. CodeGuru: Write Custom WebParts for SharePoint 2007
  2. Eric Stallworth: How To Build a Solution Pack (WSP)
  3. Stephen Huen: Microsoft Content Management Server Site Map control (C#)

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralDoesn't have indentation Pin
Member 4497991
8:15 26 Jul '09  
GeneralRe: Doesn't have indentation Pin
Curtis Shirley
8:32 28 Aug '09  
GeneralIneed to localized to another language Pin
Member 2067106
6:17 15 Jul '09  
GeneralBroken images Pin
cheong69@yahoo.com
16:52 19 Jun '09  
GeneralRe: Broken images Pin
Stephen Huen
14:08 29 Jun '09  
GeneralRe: Broken images Pin
cheong69@yahoo.com
16:24 5 Jul '09  
GeneralRe: Broken images Pin
Stephen Huen
18:05 7 Jul '09  
GeneralRe: Broken images Pin
Member 4653130
6:35 27 Jul '09  
GeneralRe: Broken images Pin
4wildkat
6:40 2 Oct '09  
GeneralRe: Broken images Pin
charmingbalu
2:18 26 Oct '09  
QuestionPublishing as well as non publishing websites Pin
.Netter
4:51 30 Jan '09  
GeneralDeep Down Pin
kundankoman
8:43 22 Jan '09  
General"Cannot import this webpart" Pin
RickyTH
22:05 3 Nov '08  
QuestionCss class Pin
lattelis
3:30 11 Jun '08  
GeneralUnable to open the solution Pin
sunil_limje
2:09 3 May '08  
GeneralRe: Unable to open the solution Pin
Stephen Huen
7:15 4 May '08  
GeneralRe: Unable to open the solution Pin
sunil_limje
0:40 5 May '08  
GeneralRe: Unable to open the solution Pin
Stephen Huen
7:06 5 May '08  
GeneralRe: Unable to open the solution Pin
sunil_limje
22:17 6 May '08  
GeneralRe: Unable to open the solution Pin
Stephen Huen
7:39 7 May '08  
GeneralLicence terms? Pin
Antti80
2:30 2 Apr '08  
QuestionInvalid SiteMapProvider: SiteMapDataSource1 Pin
Henrik Weimenhog
23:35 2 Mar '08  
GeneralRe: Invalid SiteMapProvider: SiteMapDataSource1 Pin
Stephen Huen
13:40 10 Mar '08  
GeneralHow to Pin
carlosfocker
9:27 23 Jan '08  
GeneralBuild error Pin
SharePointBloke
14:33 17 Jan '08  


Last Updated 25 May 2009 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009