zoukankan
html css js c++ java
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%>"
/>
查看全文
相关阅读:
C#时间格式转换问题(12小时制和24小时制)
ajax跨域请求webservice webconfig配置
C#时间戳转化为DateTime
C#生成缩略图
codeforces-1348-C Phoenix and Distribution
P4314 CPU监控
YangK's dfs序与树链剖分
Yangk's 静态主席树
P2253 好一个一中腰鼓!
codeforces-1341D-Nastya and Scoreboard 记忆化搜索
原文地址:https://www.cnblogs.com/jianyi0115/p/1079805.html
最新文章
Maven知识 %Eclipse%
Java泛型篇文章阅读顺序
通配符
泛型在继承上的体现
泛型在集合中的使用
泛型的理解
JSP高级 & MVC & EL & JSTL & 案例
MIME类型
将kubelet和docker的启动引擎修改为systemd
mount 挂载物理设备和挂载文件夹 对比
热门文章
kafka 常用操作
ubuntu 保持ssh的长连接
show processlist查看非sleep的sql语句
wordpress 打开debug模式
iptables nat表 添加端口转发
sql 查询指定几行数据
linux 解决tar命令的"tar: Removing leading `/' from member names"问题
C#汉字转首字母拼音
js自动执行刷新
js每隔3位加一个逗号
Copyright © 2011-2022 走看看