Moss publishing: Create a page to a sub-Folder

Source: Internet
Author: User

The page published in the moss page library yesterday is automatically saved to the root directory, even if you created it in a subdirectory.

So I found this article at jianyi: [original address]

The moss page publishing function keeps the page under the directory of the following. How can I create a page under a sub-folder?
No relevant information was found on the Internet, so I had to change the systemCode.
The publishing system page is: _ layouts/createpage. aspx.

Add the following code to 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, Int Layoutid)
{
Pagelayout [] layouts = Publishingweb. getavailablepagelayouts ();

Foreach (Pagelayout L In Layouts)
{
If(L. listitem. ID=Layoutid){
ReturnL;
}
}
Return   Null ;
}

  Void Createpage ()
{ // Bool o = publishingweb. ispublishingweb (base. Web );
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 ("batch ");
// 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 ["topic"] = 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 >

Modify the Save button event:

< ASP: button runat = " Server "   Class = " MS-buttonheightwidth " Onclick = " Createpagetocurrentfolder "
Text = " <% $ Resources: CMS, createpage_createbutton %> " ID = " Buttoncreatepage " Accesskey = " <% $ Resources: CMS, createbutton_accesskey %> " />

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.