使用具有 AllUsersWebPart 节点的功能的 SharePoint 问题
我有一个安装新页面布局的 SharePoint 功能。
此功能的要求是使用默认 Web 部件安装页面布局,以便当用户运行“创建页面”操作时,将使用页面上已有的 Web 部件创建页面。
因此,我尝试在页面的元素定义中添加 AllUsersWebPart 节点,例如。
<Elements>
...
<Module ...>
...
<File ...>
<AllUsersWebPart ...>
...
</AllUsersWebPart>
</File>
...
</Module>
</Elements>
安装、部署功能等,当然得到了有用的“没有为此对象定义无参数构造函数”错误 - 最有可能是我在 Elements.xml 中的定义有问题。
现在我遇到的真正问题是,我尝试从功能定义中删除 AllUsersWebPart 部分(以便该页面在创建时没有 Web 部件),并且由于 SharePoint 中的一个严重错误,该 Web 部件是尽管功能定义的说法不同,但仍然保留页面布局的定义 - 我在 http://sharepointblog.buus-oestergaard.dk/post/Default-webparts-in-sharepoint-pagelayouts.aspx(第 2 点)。
我尝试过升级& 删除/重新安装该功能但没有效果 - 如何从功能/内容数据库中删除此 Web 部件,以便我可以仅安装页面布局或将正确的 Web 部件定义放入功能中?
I have a SharePoint feature that installs a new page layout.
A requirement for this feature was to install the page layout with a default web part, so that when the user runs through the 'Create Page' action, the page is created with a web part already on the page.
So, I've tried adding a AllUsersWebPart node in the Elements definition of the page eg.
<Elements>
...
<Module ...>
...
<File ...>
<AllUsersWebPart ...>
...
</AllUsersWebPart>
</File>
...
</Module>
</Elements>
Installed, deployed the feature etc and of course got the helpful 'No parameterless constructor defined for this object' error - a problem with my definition in the Elements.xml most likely.
Now the REAL problem I've got is that I've tried deleting the AllUsersWebPart section from the feature definition (so that the page has no web parts on it when created) and, due to a fantastic bug in SharePoint, the web part is still left defined for the page layout, even though the feature definition says differently - I found some details about this on http://sharepointblog.buus-oestergaard.dk/post/Default-webparts-in-sharepoint-pagelayouts.aspx (Point #2).
I've tried upgrading & removing / re-installing the feature but to no effect - how can I remove this web part from the feature / content db so that I can have the feature just install the page layout or put the correct web part definition in the feature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我的页面布局开始工作了,以下是我采取的步骤,以防万一这很有用:
1 在 Web 部件页面维护模式下编辑页面布局:
从那里删除所有 Web 部件实例。
2 在 Designer 中打开布局(在服务器上),& 确保 WebPartZone / ZoneTemplate 为空。 检查此项后,确保页面布局设置为已批准。
页面布局在此之后可用 - 我能够删除 & 重新安装我的页面布局功能没有任何问题。
Web 部件定义似乎保留在数据库中,因此当更新/重新安装功能时,它们已经链接到页面/Web 部件区域。 对此进行排序可能应该在页面布局功能的功能接收器中的代码中完成,如果我有时间写这个,我会将其发布到某个地方......
Ok, I got my page layout working, these are the steps I took in case this is useful:
1 Edit the page layout in web part page maintenance mode:
Delete all web part instances from there.
2 Open the layout (on the server) in Designer, & make sure the WebPartZone / ZoneTemplate s are empty. Make sure the page layout is set to approved after checking this.
The page layout is useable after this - I was able to remove & re-install my page layouts feature without any problems.
It looks like the web part definitions are left in the database so that when a feature is updated/re-installed, they are already there linked to the page / web part zone. Sorting this out should probably be being done in code in a feature reciever in the page layout feature, if I ever get around to writing this I'll post it somewhere...
卸载该功能时,您是否确保您的页面布局已从母版页/页面布局目录中删除?
用于添加内容文件(页面布局)的功能元素在停用该功能时不会将其删除。
When uninstalling the feature, did you make sure that your pagelayout is deleted from the Masterpage/pagelayout catalog?
The feature element used for adding the content file (pagelayout) does not remove it when deactivating the feature.