다음을 통해 공유


How to: Customize the Welcome Page in SharePoint Server 2010 (ECM)

Applies to: SharePoint Server 2010

In this article
Edit a Welcome Page with the SharePoint Web-Based Editor
Customize Page Query Strings to Filter Welcome Page Content Based on Metadata Values
Specify a New Form for a Document Set Content Type

Document sets have a customizable Web Part page, the Welcome page, that by default displays an image, the properties of the document set that you specify, and the contents of the document set. This topic introduces customizations that you can make to the Welcome page at the site level and the list level.

To make changes at the site level, select the Update the Welcome Page of Document Sets inheriting from this content type. option in the user interface (UI). Save the document set settings to update the Welcome page in your document library.

Warning

Changes made by customizing the Welcome page at the list level immediately update the page for all instances of that content type.

By default, Welcome pages are not pushed down to child content types. This constraint prevents users from accidentally overwriting Welcome page customizations on child pages. We recommend making Welcome page changes only at the lowest level necessary, or by marking your content types read-only. For example, if you create a "Pitchbook" document set content type and customize the Welcome page, and then you customize the Welcome page of the base document set content type and push down that change, the "Pitchbook" customized page will be overwritten by the page from the parent document set content type. To push down the Welcome page changes to all children, select the Update the Welcome Page of Document Sets inheriting from this content type check box.

Document sets have one page for each content type, so changes made to the Welcome page for a document set content type apply to all instances of that content type. Use Web Parts to dynamically get data based on the context. For example, adding a Noteboard Web Part uses the context of the document set so that different notes show up on each specific instance of a pitchbook.

You can use three methods to customize a Welcome page:

  1. Use the Web-based SharePoint page editor by clicking the Customize the Welcome Page link from the document set Settings page.

  2. Use SharePoint Designer. You need sufficient permissions to access the All Files site object . Open SharePoint Designer, browse to the document library where the document set is stored, browse to the Forms folder, browse to the folder for your document set content type, and then open docsethomepage.aspx.

  3. Use the document set object model to implement a complete custom page. Find APIs for customizing the Welcome page in the Microsoft.Office.DocumentManagement.DocumentSets namespace.

Edit a Welcome Page with the SharePoint Web-Based Editor

Go to a custom Document Set content type that you created in the site content type gallery, click Document Set Settings, and then click the link to customize the Welcome page. A page appears that looks like the document set. On the ribbon, on the Page tab, click Edit Page to edit the page.

You can add Web Parts in four zones. Change the image to Web Part to use a different image. Add a Noteboard Web Part to the bottom of the patch so that users can leave comments. To make these changes, click Add a Web Part in Zone 4, and then select Noteboard from the Social Collaboration Web Part category.

After you are finished editing, you can save changes. On the ribbon, on the Page tab, select Stop Editing. Because the Welcome page was edited at the site level, return to the Document SetSettings page, select the check box to push Welcome page changes, and then save the document set settings. Now, navigate to a document set and see that the Web page is customized for all of the document sets.

Customize Page Query Strings to Filter Welcome Page Content Based on Metadata Values

Document set Welcome pages dynamically load content based on the content of the current document set. This means that certain Web Parts, such as the Content By Query Web Part (CQWP), may not do what you want them to. If you configure a CQWP, it will be static for each document set, and there is no way to dynamically get results based on the document set in context. You can set up CQWP to filter based on a metadata value of the page, but because there is only one Welcome page for a document set content type, this will not work with the document sets Welcome page. The most viable option is to use a page query string. However, by default, document sets probably do not provide the page query string that you want, so you need to customize it.

To implement a solution based on a customized page query string, create a Web Part that redirects to the document set Welcome page and includes a query string with the metadata value that you want to use in the CQWP. Do this by creating a Web Part that you can place on the document set Welcome page. In the .ascx file for the Web Part, insert the following code:

if (!String.IsNullOrEmpty(Request.QueryString["Column"]))
{
 
}
else
{
   string thisPage = Request.Url.AbsoluteUri; 
   integer docSetId = Request.QueryString["ID"];
    DocumentSet myItem = Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet.GetDocumentSet(templates.Items[docSetId].Folder); 
    thisPage+="&Column=";
    thisPage+=myItem["Column"].ToString();
    Response.Redirect(thisPage);  
}

The If statement checks whether the query string for Column was passed. If it was, then nothing needs to be done. Otherwise, there should be a redirect to the document set Welcome page that includes the query string. Now you can add a CQWP to use the page query string that you are passing. In the additional filters section of the CQWP, select your column, and for Custom Value or Query enter [PageQueryString: Column Name]. Now you have a CQWP that can filter based on metadata properties passed in as a query string without having to create a custom Web Part that queries for related content.

Specify a New Form for a Document Set Content Type

The form that is used to create new document sets is located in the _layouts folder on the SharePoint server. There is only one form for every document set content type. In some cases, a custom form may be needed. With a custom form you can automatically fill in metadata or add conditional formatting so that only specified fields are displayed depending on the options a user selects.

The document set content type includes a property called NewFormUrl; changing this property lets you specify what new form the content type uses. Changing this property enables you to specify a custom new form for each document set content type. Before changing this property, create a new .aspx page and store it in the _layouts folder, or in a folder in _layouts. If you store the form in a folder, add a web.config file that includes the document set assembly, which is required to use the document set object model to create a document set.

The following example demonstrates a customized new document set page: first, the customdocumentset.aspx code-behind page, and then the customdocumentset.cs code page.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="CustomNewDocset.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <asp:Literal ID="litList" runat="server" />
    <asp:Literal ID="litCt" runat="server" />
</body>
</html>
 
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
SPList list = SPContext.Current.List;
litList.Text = list.Title;
SPContentTypeId ctid = new SPContentTypeId(Request.QueryString.GetValues("ContentTypeId")[0]);
SPContentType ct = list.ContentTypes[ctid];
litCt.Text = ct.Name;
    }
}

The web.config file is the configuration file that must be placed in the folder that contains the custom new document set .aspx page. The web.config file is required, or the document set object model cannot be accessed. Add references to other assemblies as needed. If the custom new document set page is placed in the root of the _layouts folder rather than in another folder, then you do not need the web.config file.

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to editing this file manually, you can use the 
    Web admin tool to configure settings for your application. Use
    the Website->ASP.NET Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments, which is usually located in the 
    \Windows\Microsoft.Net\Framework\v2.x\Config directory.
-->
<configuration>
<system.web>
<!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
<compilation debug="false">
<assemblies>
<add assembly="Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=94DE0004B6E3FCC5"/>
</assemblies>
</compilation>
</system.web>
</configuration>

To use the custom new document set page, the URL for the document set content type must be updated. The next example is a Windows PowerShell script that can be used. Pass in the URL to the site that contains the document set content type that you want to change. Specify the appropriate content type ID for the ctid of the content type that you want to change. SharePoint Server updates the NewFormUrl property to use the customized new document set page instead of the default. The $siteurl string should be the URL that has the custom document set content type. The $ctid string is the content type ID of the document set that is being modified. The $contentType.NewFormUrl setting is the location in relation to the _layouts folder that contains the custom new document set form.

$siteUrl = "http://mysite"
$ctid = "0x0120D520"
param($siteUrl)
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$web = $site.RootWeb; 
$contentTypeId = New-Object Microsoft.Sharepoint.SPContentTypeId($ctid)
$contentType = $web.ContentTypes[$contentTypeId]
$contentType.NewFormUrl = "_layouts/CustomNewDocset/CustomNewDocset.aspx"
$contentType.Update()
$web.Dispose()
$site.Dispose()

After you run the Windows PowerShell script, SharePoint Server creates a new custom document set page and changes the value of the newFormUrl property to the new page. When you use the New Document drop-down list in a document library to create a new document set, the custom page appears.

See Also

Tasks

How to: Create a New Document Set Form in SharePoint Server 2010 (ECM)

Reference

DefaultDocumentCollection

WelcomePageFields

FieldLinks

Concepts

Document Sets in SharePoint Server 2010 (ECM)