I'm trying to analyse how an existing MOSS 2007 publishing site is composed but I don't see any obvious way of identifying the type of the various web parts already in use within pages. Is there any way of telling definitively?
3 Answers
You can add ?contents=1
to the end of your page's URL to get a nice neat list of all the webparts that are currently opened and closed:
http://sharepointsolutions.blogspot.com/2008/04/when-good-web-parts-go-bad.html
Are you an author on the page? You can export a Web Part and look at the XML to see what object it references.
If you're trying to figure it out using the rendered source, that's not 100% reliable... well built Web Parts don't exactly add markup/code to advertise what they are as that adds unnecessary markup to the page weight.
For publishing sites (specifically the content regions), if they were done the right way, they used field controls and not Web Parts.
-
I'm a site collection administrator if that's any help. If there's a way of enumerating them programmatically I'd be prepared to write something to sit in the MasterPage and list their types if absolutely necessary. Not all the web parts are exportable so I can't rely on that XML unfortunately. Seems crazy to me that it isn't easier to tell their types. And I don't think saving on page weight has ever concerned a developer of any part of Sharepoint I've ever seen. What do you mean by using field controls instead of Web Parts by the way? Surely they solve very different problems?– stovrozFeb 22, 2011 at 21:32
In case anyone's interested I came up with the following solution based on the http://spservices.codeplex.com/ jQuery library, before seeing Kit's rather more straight forward approach in the accepted answer. Still, might be of some use one day:
$().SPServices({
operation: "GetWebPartProperties2",
pageUrl: window.location.pathname,
storage: "Shared",
completefunc: function (xData, Status) {
$(xData.responseXML).find("type").each(function() {
$("body").append("<li>" + $(this).attr("name") + "</li>");
});
}
});