Intranet Journal
The online resource for intranet professionals
Customizing the Quick Launch in a WSS Team Site
Paul Schaeflein
7/15/2005
|
|
Editor's Note: The rest of Paul's series, and more Microsoft SharePoint content, can be found at: www.intranetjournal.com/sharepoint/.
Team sites in Windows SharePoint Services (WSS) contain a special navigation feature called the Quick Launch. The Quick Launch is on the home page and provides links to the Document Libraries, Lists, Picture Galleries, Discussions and Surveys. One of the benefits of the Quick Launch is that when new items (libraries, lists, etc.) are added to the site, the creator can choose to include a link to the item on the Quick Launch.
The Quick Launch is composed of several components, called Link Bars. There is one link bar for each of the categories: Document Libraries, Lists, Picture Galleries, Discussions, and Surveys. Using FrontPage 2003, a Web designer can view these link bars while editing the home page. Additionally, the individual link bars can be added to any page in the site. (Link bars can also be created manually.)
This month, I will present a solution to provide this automatic link functionality for documents in a Document Library.
Built-In Quick Launch Functionality
|
Before continuing, I want to review the functionality of the built-in Quick Launch. Experienced SharePoint users/administrators may want to skip to the next section.
On the home page of Team sites in Windows SharePoint Services (WSS), the left side of the page has a series of links titled Quick Launch. The links are grouped by category and they point to the default view of the library/list.
When new libraries,lists,etc. are added to the site, the create page function allows the creator to include the list on the Quick Launch. (This setting can be changed later if desired.) For frequently accessed libraries and lists, this feature is very useful. Be aware, however, that links in the Quick Lauch are displayed in the order they are added. Re-arranging the links requires FrontPage 2003.
One common request for the Quick Launch is the ability to link to individual items in a document library rather than linking to the default view of the library. While this is not part of the built-in feature set, it is easily available via a custom web part.
Document Library Quick Launch
As I discussed in my previous article, I have created a custom Web Part that will display links to items stored in a document library. While creating this part, I felt it would be helpful to allow site authors to exclude documents and to allow specify the order of the links. In addition, the part would only be useful if it dynamically rendered based on the contents of the document library.
Download and Install the Web Part
To get started, download the Web Part (including the source code) from my Weblog at http://www.schaeflein.net/blog/DocumentLibraryQuickLaunchWebpart.aspx. The file contains a CAB file of the Web Part that can be installed using the command-line administration tool STSADM.EXE. The STSADM tool will place the Web Part in the Virtual Server gallery, which makes it available to all Web Part pages on that server.
If you are familiar with Web Part development, you can compile the source and make the resulting Web Part control (.dll file) available in your usual manner.
Configure Document Library
To meet the first two requirements, I decided that the custom Web Part would look for a column in the document library named SortOrder. Columns are added to document libraries in the same way they are added to lists. (Behind the scenes, a document library is built on a list, as we will see in the source code.)
Perform the following to add this column to your document library:
If the value of this column is not blank and is greater than zero, the document will be displayed in the Document Library Quick Launch.
Add the Web Part to the Page and Set Its Properties
After setting the SortOrder value on the desired pages in the document library, you can add the Web Part to a Web Part page. Please refer to the previous article in this series for specifics about configuring the Web Part.
How It Works
The Document Library Quick Launch Web Part uses SharePoint's object model to list all of the documents that meet the criteria. Information about the object model, and about creating custom Web Parts, can be found on Microsoft's SharePoint developer center (http://msdn.microsoft.com/sharepoint/). The WSS Software Developers Kit (SDK) can also be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyId=1C64AF62-C2E9-4CA3-A2A0-7D4319980011&displaylang=en.
Dim mySite As SPWeb = SPControl.GetContextWeb(Context)
Dim myList As SPList = mySite.Lists(qlDocLibName)
If myList.BaseType = SPBaseType.DocumentLibrary Then
Dim docLibrary As SPDocumentLibrary = CType(myList, SPDocumentLibrary)
If Not docLibrary.IsCatalog Then
If myList.BaseTemplate <> SPListTemplateType.XMLForm Then
Dim docLibItems As SPListItemCollection = docLibrary.Items
Dim docLibItem As SPListItem
For Each docLibItem In docLibItems
qlItem = New QuickLaunchItem
qlItem.SortOrder = docLibItem("SortOrder")
qlItem.Title = docLibItem("Title")
qlItem.URL = docLibItem.File.ToString
If CInt(qlItem.SortOrder) > 0 Then _
qlDocLibItems.Add(qlItem.SortOrder, qlItem)
Next docLibItem
End If
End If
End If
|
At the risk of getting too technical, I want to point out a few items about the GetDocumentLinks routine creates this list.
The item to note in this code is that the document library is actually a list, and is retrieved using the List property of the site object. The List object is then tested to ensure it is a document library and that it contains documents, not XML (InfoPath) forms.
If you would like additional information about the Web Part, post an comment to the Intranet Journal forum or contact me thru my Weblog.
About this series
This series of articles on SharePoint is intended to help you understand the capabilities of the product, as well as provide tips and tricks, development ideas, information from Microsoft, information from the community, and perhaps some samples. Like many other series on IntranetJournal.com, I plan to include how-to articles that can help you with your deployments — ways to customize a page; deployment scenarios; content management; etc. With such a diverse product, there is no lack of topics for this series of articles. What would you like to read?
About the author
Paul Schaeflein is a developer with more than 20 years experience. Paul has been developing dynamic and interactive Web sites since 1996. Paul has worked on all of the versions of SharePoint and has worked with the .NET framework since its debut. You can reach Paul through his blog at http://www.schaeflein.NET/blog/.
Intranet Journal's Tutorials |
|
Managing Editor |