1

我正在尝试制作一项功能以在“页面”库中上传新的发布页面,但它不能按我想要的方式工作。如果我使用 SharePoint Designer 查看库,则会显示我的发布页面,但如果我使用 Internet Explorer,则不会。

在该功能中,我配置了以下属性:ContentTypeId、ContentTye、Author、Title、FileRef、FileDirRef、FileLeafRef、FileType、LinkFilenameNoMenu、LinkFilename 和 DocIcon。在以前的功能中,我遇到了同样的问题,并且解决了放置 ContentTypeId 属性。在这种情况下,我不知道错误在哪里。

4

4 回答 4

1

我使用以下代码基于页面布局创建发布页面,该页面布局被认为已配置并基于内容类型。代码在您的功能的 FeatureActivated 事件处理程序中运行:

    using (SPWeb ParentWeb = properties.Feature.Parent as SPWeb)
    {
            PublishingWeb webpublish = PublishingWeb.GetPublishingWeb(ParentWeb);

            //retrieve the layout associated with our custom content type
            PageLayout[] layouts = webpublish.GetAvailablePageLayouts(new SPContentTypeId(MyContentTypeID));

            //first layout considered, as this is the one created by this feature
            PageLayout MyPageLayout = layouts[0];

            PublishingPageCollection PublishingPages = webpublish.GetPublishingPages();

            PublishingPage newPage = PublishingPages.Add("NewPublishingPageName.aspx", MyPageLayout);
            newPage.Title = "My first publishing page";

            newPage.ListItem.Update();

            //check-in and republish the page
            SPFile listItemFile = newPage.ListItem.File;

            //check that the file is not checked out - if it is,  check it in.
            if (listItemFile.CheckOutStatus != SPFile.SPCheckOutStatus.None)
            {
                listItemFile.CheckIn("Initial default content added.");
            }

            listItemFile.Publish("");
            listItemFile.Approve("");                
    }
于 2009-05-04T08:30:54.103 回答
1

参考这些链接

http://blog.mastykarz.nl/provisioning-publishing-pages-features-declarative-markup/

于 2009-06-11T07:52:25.790 回答
0

我有一个类似的问题。事实证明,我必须发布上传的文件才能使其可见。

于 2009-05-03T14:45:10.013 回答
0

我有与 Tudor 类似的解决方案,我将发布该代码以防万一:

...获取 SiteCollection (SPSite)...

PublishingSite pSite = new PublishingSite(site);
PageLayout layout = pSite.PageLayouts["MyLayout"];

PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(site);

if(pWeb.GetPublishingPages()[pWeb.PagesList.Title + "/" + "MyPage.aspx"] == null)
{
  PublishingPage page = pWeb.GetPublishingPages().Add("MyPage.aspx", layout);
  page.Title = "MyTitle";
  page.Update();
  page.CheckIn("Added MyPage.aspx");
}
于 2009-06-04T16:25:52.530 回答