Create a news website under the MOSS

News of the principle of MOSS, with the ordinary notification list is different, each MOSS news is the news a page, Pages document library page is stored in the site.

Create a manual News
Site Actions, choose to create a page under

the following interface is as follows :( Click image clarity map) Enter the appropriate content in the input box, and select "page layout article page (article page) contains the image of the left ." point "create" to create a blank page news, news headlines and other content input in this page Chinese box, point to an increase of a news release. News Release may also use the process, not repeat them here. Create a news program above we use manually create news, we sometimes need to publish news program, as a practical application for approval has the article, after several approvals, if leaders choose to publish news website, then we need to use the program content of the article as a press release. Said a lot, we in the end how to do it? First, we need to reference the following assemblies, assemblies can be found in the following directory: C: \ Program Files \ the Common Files \ in the Microsoft Shared \ Web Server Extensions \ 12 \ ISAPI Microsoft.SharePoint.dll Microsoft.SharePoint.Portal.dll Microsoft.SharePoint .Publishing.dll program code:












using  Microsoft.SharePoint;
using  Microsoft.SharePoint.Publishing;

// 发布新闻的部分代码,其它省略
// ……

SPSite site 
=   new  SPSite( " siteUrl " ); 
SPWeb web 
=   null ;
PublishingSite pubsite 
=   null ;
PublishingWeb pubweb 
=   null ;


try
{
   
// get the PublishingWeb
   web = site.OpenWeb("/"); //顶级网站
   
//pubsite = new PublishingSite(site);
   pubweb = PublishingWeb.GetPublishingWeb(web);

   
// 这里的ID是我们上一步手工创建时页面布局“(文章页面)左侧包含图像的文章页面”对应的内容类型
   
// 页面布局都有一个相应的内容类型用于储存数据
   SPContentTypeId articleContentTypeID = new SPContentTypeId("0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D");

   
// 获取(文章页面)左侧包含图像的文章页面的页面布局 
   PageLayout[] layouts = pubweb.GetAvailablePageLayouts(articleContentTypeID);
   PageLayout articlePageLayout 
= layouts[PageLayoutIndex];

   
// 生成新闻页面的文件名
   string pageName = DateTime.Now.ToString("yyyyMMdd-HHmmss");

   
// 创建新闻页面
   PublishingPage newpage = pubweb.GetPublishingPages().Add(pageName + ".aspx", articlePageLayout);
   newpage.ListItem[
"标题"= "这是新闻标题";
   newpage.ListItem[
"作者"= "作者";
   newpage.ListItem[
"页面内容"= "这是文章内容";
   newpage.ListItem [
" article Date " =  DateTime.Now;
   newpage.Update ();
   newpage.CheckIn (
" CheckIn " );  // check    SPFile PageFile  =  newpage.ListItem.File;    pageFile.Publish ( " published by the code " ); }


the catch  (Exception EX) {     LogError (ex.Message);  // logging method is omitted here } the finally {     web.Dispose ();     site.Dispose (); }








Our press release on this success.

Reproduced in: https: //www.cnblogs.com/baoposhou/archive/2007/11/20/965226.html

Guess you like

Origin blog.csdn.net/weixin_33920401/article/details/93320746