惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
U
Unit 42
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Martin Fowler
Martin Fowler
L
LangChain Blog
博客园_首页
博客园 - 【当耐特】
Vercel News
Vercel News
I
InfoQ
GbyAI
GbyAI
爱范儿
爱范儿
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
美团技术团队
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
H
Help Net Security
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
D
Docker
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
小众软件
小众软件
J
Java Code Geeks
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
The Cloudflare Blog
Recorded Future
Recorded Future
阮一峰的网络日志
阮一峰的网络日志
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - 范文轩

SharePoint 2010中的WebProvisioned Event Handler 如何向列表中添加数据值(开发篇补充REST) 如何向列表中添加数据值(开发篇) 如何向列表中添加数据值(管理员篇) 在SharePoint 2010中动态加载Visio Web Part 使用编程的方式来启动SharePoint的工作流 InfoPath 2010调用REST的一个小应用 SharePoint 2010 WSP包部署过程中究竟发生什么? 如何查看SharePoint 2010的CU版本 SharePoint 2010多语言包的安装 在SharePoint 2010中使用Linq时候,请注意特殊字符 自定义ASP.NET WebApplication中调用SharePoint2010的对象 在Infopath 2010中调用Web Service 谈谈SharePoint 2010的客户端对象模型的性能问题 给Document Set里面添加文件夹 给Chart Web Part 添加过滤功能 SharePoint 2010的Form认证的用户注册功能 SharePoint 调查列表的自定义错误页面 Reporting Services 2008 and SharePoint 2010
Sharepoint中的Feature Stapling功能
范文轩 · 2012-02-15 · via 博客园 - 范文轩

在上一篇http://www.cnblogs.com/fanwenxuan/archive/2012/02/15/2353115.html中我介绍了“WebProvisioned”的应用,并且提出了一些疑问。那么对于一下问题的解决方案是什么?

需求: 我现在有一个新的需求,当用户新建“博客”或者“工作组”站点的时候,我要在站点里面新建一个列表;或者说当用户新建“我的站点”的时候,我想要在每个用户自己的站点上加上点东西,怎么办?

我们可以直接去修改站点定义,譬如说修改“工作组”站点的定义文件,当时微软是不建议修改这些文件的。所以我们的方案是使用Feature Stapling功能。我对这个功能的理解是:通过Feature的方式来修改站点定义。他的作用范围是整个Farm。也就是你激活这个Feature Stapling之后,在任何位置新建站点,都会触发你的feature功能。

具体步骤:

1.创建一个”列表定义”的Feature

   1:  <?xml version="1.0" encoding="utf-8"?>
   2:  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:    <ListInstance Title="FlyFeatureStaper - FlyList0215"
   4:                  OnQuickLaunch="TRUE"
   5:                  TemplateType="107"
   6:                  FeatureId="00bfea71-a83e-497e-9ba0-7a5c597d0107"
   7:                  Url="Lists/FlyTask"
   8:                  Description="Fly task">
   9:    </ListInstance>
  10:  </Elements>
   1:  <Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="FlyFeatureStaper Feature1" Id="6f4f155e-64a7-467b-9aa9-602e7e3ebdcf" Scope="Web">
   2:    <ElementManifests>
   3:      <ElementManifest Location="FlyList0215\Elements.xml" />
   4:    </ElementManifests>
   5:  </Feature>

这个Feature的范围可以是web,site,或者其他,他的内容可以是Event Handler, Workflow,或者Web Part等等

2.创建一个新的Feature(Scope必须是Farm级别),并且新建一个空的Element文件。

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="FlyFeatureStaper Feature2" Id="a30110c8-df7a-4b23-9e14-383cd453a7cb" Scope="Farm">
  <ElementManifests>
    <ElementManifest Location="FlyStapler0215\Elements.xml" />
  </ElementManifests>
</Feature>

Element.xml文件

   1:  <?xml version="1.0" encoding="utf-8"?>
   2:  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:    <FeatureSiteTemplateAssociation Id="6f4f155e-64a7-467b-9aa9-602e7e3ebdcf"
   4:                                    TemplateName="STS#0"/>
   5:  </Elements>

这里需要注意的是里面的Id和TemplateName两个值。Id表示你要stapling的Feature的Id,这里也就是我的第一个feautre的ID;TemplateName表示要起作用的站点定义。STS#0表示工作组站点。你可以通过“Get-SPWebTemplate” powershell命令来获取所有的站点定义:例如http://virtualizesharepoint.com/2011/06/15/how-to-find-the-template-name-of-sharepoint-site/ 

最后一步,部署Feature。 Feature Stapling需要在Farm Features中激活。

结果:新建工作组站点的时候,会自动创建一个名称为“FlyFeatureStaper - FlyList0215”的任务列表。

更多场景:当你想在“我的站点”中添加一些页面,或者Web Part的时候,可以通过Feature Stapling的方式实现。

更多内容参考:http://sharepointmagazine.net/articles/introduction-to-sharepoint-feature-stapling-part-1

http://www.sharepointnutsandbolts.com/2007/05/feature-stapling.html