Sharepoint 查找正在使用 webpart 的位置

发布于 2024-08-06 01:19:55 字数 122 浏览 1 评论 0原文

是否可以分析某个 Web 部件在哪些页面上使用?

我想从我的共享点服务器中删除一些 Web 部件,但我不知道哪些在使用,哪些没有在使用?

有解决办法吗?

我目前使用 moss2007

Is it possible to analyse on which pages a webpart is in use?

I want to remove some webparts from my sharepoint server, but i don't know what's in use and what's not in use?

Is there a solution for it?

Im current using moss2007

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

简单 2024-08-13 01:19:55

添加到页面的每个 Web 部件都存储在页面本身中。没有中央存储来记录每个 Web 部件的使用位置。

不幸的是,这意味着您需要遍历站点中的每个 Web 部件页面才能检索此信息。然后,您应该在每个页面上检查 Web 部件的程序集名称。将找到的所有 Web 部件添加到应用程序完成后输出的列表中。

SPWeb 对象允许您使用 SPWeb.GetLimitedWebPartManager()。使用 SPLimitedWebPartManager.WebParts 属性检索 Web 部件的集合。

Each web part added to a page is stored in the page itself. There's no central store that records where each web part is used.

This means unfortunately you need to iterate through every web part page in the site to retrieve this information. On each page you should then check the assembly names of the web parts. Add all the web parts you find to a list that is output once the application's completed.

The SPWeb object allows you to retrieve the web part manager for each page with SPWeb.GetLimitedWebPartManager(). Use the SPLimitedWebPartManager.WebParts property to retrieve a collection of web parts.

你爱我像她 2024-08-13 01:19:55

Alex 的答案(迭代网站 -> 页面 > Web 部件)很好,并且是执行此操作的“正确”方法但在一个非常大的网站上相当昂贵。

另一种方法是数据库查询。所有关于直接访问数据库的常见注意事项都适用:不要更改任何内容,可能会随时因服务包等而中断,但假设我们都是这里的大男孩:-

首先您需要找出 WebPartTypeId

接下来在所有内容数据库上运行此操作。

SELECT DISTINCT D.SiteID, D.WebId, W.FullURL as WebURL, D.Id As DocumentId,
                D.DirName, D.LeafName, tp_ID As WebPartSK
FROM       dbo.Docs D WITH (nolock) 
INNER JOIN dbo.Webs W WITH (nolock) ON D.WebID = W.Id
INNER JOIN dbo.WebParts WP WITH (nolock) ON D.Id = WP.tp_PageUrlID
WHERE WP.tp_ListId Is Null AND WP.tp_Type Is Null AND WP.tp_Flags Is Null
      AND WP.tp_BaseViewID Is Null AND WP.tp_DisplayName Is Null 
      AND WP.tp_Version Is Null
AND WP.tp_WebPartTypeId='<your web parts id>'

您可以以相反的方式执行此操作(获取所有正在使用的 WebPartTypeId 的列表),但您无法从 WebPartTypeId 哈希中获取程序集名称,因此您必须执行某种 Web 部件查找列表 > typeid 的。

Alex's answer (iterating through sites -> pages > web parts) is good and the 'correct' way to do this but is fairly expensive on a very large site.

An alternative is a database query. All the usual caveats apply about accessing the database directly : do not change anything, could break at any time with service packs etc etc but assuming we are all big boys here :-

First you need to find out the WebPartTypeId of the web part your interested in

Next run this on ALL content databases.

SELECT DISTINCT D.SiteID, D.WebId, W.FullURL as WebURL, D.Id As DocumentId,
                D.DirName, D.LeafName, tp_ID As WebPartSK
FROM       dbo.Docs D WITH (nolock) 
INNER JOIN dbo.Webs W WITH (nolock) ON D.WebID = W.Id
INNER JOIN dbo.WebParts WP WITH (nolock) ON D.Id = WP.tp_PageUrlID
WHERE WP.tp_ListId Is Null AND WP.tp_Type Is Null AND WP.tp_Flags Is Null
      AND WP.tp_BaseViewID Is Null AND WP.tp_DisplayName Is Null 
      AND WP.tp_Version Is Null
AND WP.tp_WebPartTypeId='<your web parts id>'

You could do this the other way around (get a list of all WebPartTypeId's in use) but you can't get the assembly name from the WebPartTypeId hash so you would have to do some sort of lookup list of web parts > typeid's.

南渊 2024-08-13 01:19:55

另一种方法是使用 Gary Lapointe STSADM 扩展,特别是 enumPageWebParts

stsadm -o gl-enumpagewebparts -url "http://intranet/hr/pages/default.aspx" -verbose

它仅输出特定页面上使用的 Web 部件,但您可以为每个页面调用此方法您的站点,甚至添加一个命令来迭代站点中的所有页面。

http://stsadm.codeplex.com/

Another way to do this is use Gary Lapointe STSADM extensions,specifically enumPageWebParts

stsadm -o gl-enumpagewebparts -url "http://intranet/hr/pages/default.aspx" -verbose

It only outputs the web parts in use on a specific page but you could call this for each page on your site or even add a command to iterate over all pages in a site.

http://stsadm.codeplex.com/

吐个泡泡 2024-08-13 01:19:55

如果有人正在寻找 SharePoint 2013 的相同查询。就在这里。该视图已于 2013 年删除,具有相同字段的表名称为 dbo.AllWebParts。

SELECT DISTINCT D.SiteID, D.WebId, W.FullURL as WebURL, D.Id As DocumentId,
                D.DirName, D.LeafName, tp_ID As WebPartSK
FROM       dbo.Docs D WITH (nolock) 
INNER JOIN dbo.Webs W WITH (nolock) ON D.WebID = W.Id
INNER JOIN dbo.AllWebParts WP WITH (nolock) ON D.Id = WP.tp_PageUrlID
WHERE WP.tp_ListId Is Null AND WP.tp_Type Is Null AND WP.tp_Flags Is Null
      AND WP.tp_BaseViewID Is Null AND WP.tp_DisplayName Is Null 
      AND WP.tp_Version Is Null
AND WP.tp_WebPartTypeId='<your web parts id>'

And in case anyone is looking for the same query for SharePoint 2013. Here it is. The view has been removed in 2013 and the table name that has the same fields is dbo.AllWebParts.

SELECT DISTINCT D.SiteID, D.WebId, W.FullURL as WebURL, D.Id As DocumentId,
                D.DirName, D.LeafName, tp_ID As WebPartSK
FROM       dbo.Docs D WITH (nolock) 
INNER JOIN dbo.Webs W WITH (nolock) ON D.WebID = W.Id
INNER JOIN dbo.AllWebParts WP WITH (nolock) ON D.Id = WP.tp_PageUrlID
WHERE WP.tp_ListId Is Null AND WP.tp_Type Is Null AND WP.tp_Flags Is Null
      AND WP.tp_BaseViewID Is Null AND WP.tp_DisplayName Is Null 
      AND WP.tp_Version Is Null
AND WP.tp_WebPartTypeId='<your web parts id>'
GRAY°灰色天空 2024-08-13 01:19:55

我没有通过任何方法成功生成 Web 部件类型 id,当我执行查询时,我根本没有得到任何结果。这是因为 id 从来都不正确。

为了解决这个问题,我创建了一个新页面并插入了我感兴趣的 Web 部件的实例。然后我通过 LeafName 进行查询,为其提供我创建的页面(最好使其独一无二!)。这返回了一个结果,然后我可以使用它返回的 tp_WebPartTypeId 来查询整个内容数据库。

因此,如果您在生成 id 时遇到问题,请尝试此方法。

I've had no success generating the web part type id by any method, I simply get no results when I execute the query. This was because the id was never correct.

To get around this issue, I created a new page and inserted an instance of the web part I was interested in. I then query by LeafName, giving it the page I'd created (Best to make it unique!). This returned a single result and I could then use the tp_WebPartTypeId it returned to query the entire content database.

So if you're having trouble generating the id, try this approach instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文