views:

1172

answers:

6

I have an announcements list on one site. I want to add it as a web part to the top of each subsite. How can I do this in MOSS?

+2  A: 

I've used the Data View Web Part in this case. Create a web service data source to get the data from the other site's list.

Much like this:

http://www.sharepointblogs.com/ssa/archive/2007/02/23/showing-web-service-data-in-a-data-view-web-part.aspx

Eugene Katz
A: 

Out of box that is not possible. Lists are limited to one site only.

The only option you have is to use content query web part (available in SharePoint Standard or better).

Here is how you can use CQWP.

There is also enhanced - community edition here.

You can embed these in your subsite templates.

Toni Frankola
A: 

You should be getting the SPList object of that particular list using SharePoint Object Model. Once u get the same, you can render the list using the RenderAsHtml() Method. Please note that the RenderAsHtml() Method takes an SPQuery Object as parameter. You need to create an SPQuery object with the appropriate Query string. This code could go into the override of the RenderWebPart() method of a custom webpart:

SPSite site = new SPSite(siteURL);

SPWeb web = site.OpenWeb(webName);

SPList list = web.Lists[listName];

SPQuery query = new SPQuery();

query.Query = queryString;

string html = list.RenderAsHtml(query);

output.Write(html); //output is the HtmlTextWriter object in the RenderWebPart method.

ashwnacharya
A: 

The Content Query Web Part or the open source Enhanced Content Query Web Part are good ways to accomplish this.. If you don't have MOSS but WSS, Mr. Katz's and Mr. Ashwin's answers are acceptable but different ways to answer this question.

Tom Resing
Well I said that it is available only in SharePoint Standard or better.
Toni Frankola
I have corrected the question. I meant MOSS when I asked the question.
Ryan Michela
Frenki, you did say that. No disrespect meant.Ryan, thanks for clarifying.
Tom Resing
+1  A: 

A couple of points.

First, you specified that you are using WSS 3.0, so the CQWP is not available (you need MOSS and to have publishing turned on for this to be available). The enhanced community edition will also not work for you since it derives from the CQWP.

Second, I would agree with Eugene Katz that a DataFormWebPart would be an easy approach, and I have a slightly different way of producing it than the link he posted presents. In Sharepoint Designer, open your desired site you want to place the web part on. Select the Data Source Library from the Task Panes menu, then click on "Connect to another library..." at the bottom of the pane, and browse/select your parent site that contains the announcement list. Now you can just add your announcement as a DataFormWebPart from the newly created node on the Data Source Library pane just as if it was on your site. Sharepoint Designer help shows how to do this if you are unfamiliar.

After you have set up your DataFormWebPart to your liking, you can make adding this to additional sites much easier by doing the following: Highlight your newly built DataFormWebPart and select File/Export/Save Web Part to.../Site Gallery. It will now be available throughout the site collection as an addable web part.

barryd
A: 

A really great web part for doing this is the Content By Type web part on Codeplex. It also supports showing items of a given content type from any list in any subsite.

See: http://www.codeplex.com/eoffice

Daniel O