MOSS publishing功能:创建页面到子文件夹

MOSS的页面发布功能,页面始终保存到跟目录下,如何使页面创建到子文件夹下呢?

网上没有找到相关的资料,只好改一下系统的代码了。

publishing的系统页面是: _layouts/CreatePage.aspx.

添加以下代码到CreatePage.aspx:
<% @ Import Namespace="Microsoft.SharePoint"  %>
<% @ Import Namespace="Microsoft.SharePoint.Publishing"  %>
< script  runat ="server" >
string _folderUrl ;
int _layoutId ;
string _pageName ;
 
void   CreatePageToCurrentFolder(object sender, EventArgs e)
{    
    _folderUrl 
= "" + Request.QueryString["RootFolder"];    
    _layoutId 
= Convert.ToInt32( dropdownList.SelectedValue );    
    _pageName 
= this.urlNameTextBox.Text.Trim() + ".aspx" ;        
    CreatePage();
}


PageLayout GetPageLayout( PublishingWeb publishingWeb , 
int layoutId)
{
    PageLayout[] layouts 
= publishingWeb.GetAvailablePageLayouts(); 
        
    foreach( PageLayout l 
in layouts )
    
{
       
if( l.ListItem.ID == layoutId){
           
return l ;
        }

    }
    
    
return null  ;
}


 
void CreatePage()
{                     //bool o = PublishingWeb.IsPublishingWeb(base.Web) ;        
        PublishingWeb publishingWeb 
= PublishingWeb.GetPublishingWeb(base.Web);
        PublishingSite site 
= new PublishingSite(base.Web.Site);         
        
//if (publishingWeb.GetPublishingPages()["Pages/my1.aspx"] == null)        
        
//Create the default page        //SPContentTypeId contentTypeID = new SPContentTypeId("0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900916CECA7C77446059633C4287903AA2A");
        //PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts();      
        
//PageLayout selectedPageLayout = layouts[0];                
        PageLayout selectedPageLayout 
= GetPageLayout( publishingWeb , _layoutId ) ;                
        string fullPagePath 
= _pageName ;        
        
if( _folderUrl != "" )
            fullPagePath 
= _folderUrl + "/" + _pageName ;
        PublishingPage newPage 
= publishingWeb.GetPublishingPages(1).Add(  fullPagePath  , selectedPageLayout);          
       
// newPage.Title = this.urlNameTextBox.Text.Trim() ;        
         newPage.Update();        
       SPListItem item 
=  publishingWeb.PagesList.GetItemById( newPage.ListItem.ID );       
        item[
"Title"= this.urlNameTextBox.Text.Trim() ;   
       
// item["主题"] = this.urlNameTextBox.Text.Trim() ;   
        item.Update();
        
//Set the default page
        SPFile welcomeFile = base.Web.GetFile(newPage.Url);
        
//publishingWeb.DefaultPage = welcomeFile;     
        string webUrl 
= publishingWeb.Url;
        
if (!webUrl.EndsWith("/"))
            webUrl 
+= "/";
        Page.Response.Redirect(webUrl 
+ newPage.Url + "?ControlMode=Edit&DisplayMode=Design");
        
//publishingWeb.Update();        
}

</ script >

修改保存按钮事件:
< asp:Button  runat ="server"  class ="ms-ButtonHeightWidth"  OnClick ="CreatePageToCurrentFolder"
Text
="<%$Resources:cms, createpage_createbutton%>"  id ="buttonCreatePage"  AccessKey ="<%$Resources:cms,createbutton_accesskey%>" />

你可能感兴趣的:(文件夹)