【问题标题】:How can i change the site definition default welcome page如何更改站点定义默认欢迎页面
【发布时间】:2011-09-22 13:02:06
【问题描述】:

我是 sharepoint 2010 开发人员的新手,我正在创建站点定义,但我无法使用 onet.xml 文件更改默认欢迎页面,我尝试了所有可能的方法,但失败了,请任何人帮忙?

如果可以的话,我想要一个带有自定义欢迎页面的站点定义,称为主页。

【问题讨论】:

  • 你应该在 sharepoint.stackexchange.com 上尝试这个问题

标签: sharepoint sharepoint-2010


【解决方案1】:

使用以下接收器创建一个网络范围的功能

   public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        try
        {
            var currentWeb = (SPWeb) properties.Feature.Parent;
            var pubWeb =  PublishingWeb.GetPublishingWeb(currentWeb);

            SPFile homePageFile = currentWeb.GetFile("Pages/custompage.aspx");
            pubWeb.DefaultPage = homePageFile;

            pubWeb.Update();
        }
        catch (Exception e)
        {
                 //log etc..
        }
    }

不要忘记引用 Microsoft.SharePoint.Publishing dll。

使用特征装订。功能装订参考http://msdn.microsoft.com/en-us/library/ff382738(v=office.12).aspx.

将以下代码添加到您的 ONET.xml 不要忘记激活发布功能。

<Configurations>
        <Configuration ID="0" ...>

        <WebFeatures>
                         <!-- Publishing Feature ID -->
                        <Feature ID="GUID" />
                         <!-- Your Feature ID -->
            <Feature ID="GUID" />
        </WebFeatures>

</Configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-03
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-04
    • 2010-10-21
    • 2021-11-25
    • 2014-09-03
    相关资源
    最近更新 更多