I have a list or a library in a SharePoint site that I want to show as a webpart on my page. Simple..? Yes, if the list or library in in the same site collection, or child site as the page that you want to display it on. Not is the library is in a separate site collection.
There are a couple of ways of doing this. One is to create a SharePoint solution in Visual Studio & programatically code up a webpart connection to the library that you want as your source & then iterate through the library object writing some code to the page to show file names & other properties etc.
The method I am going to describe below is a quick fix solution to the problem using SharePoint Designer.
Basically, you create an aspx page in the source site collection that is hosting the library you want to reference. You add a list viewer webpart to this page & use that to show the library, (still in the source site collection). Then from your other site collection where you want to show the library you use a Page Viewer webpart to reference the aspx page from the other site collection.
Step by Step…
Actions in the source site collection…
- Open your source site in SharePoint Designer, (thats the site containing the document library in question).
- Click on “Site Pages” in the left hand menu
- Click on the small down arrow under the “Page” icon on the top menu ribon & select ASPX. Give your new file a suitable name.
- Click on the name of the file to open it, & then select “Edit File” in the control panel. You should get a warning message that says…”This page does not contain any regions that are editable…..” Just click on “Yes”.
- At this point you will need to save the file in order to activate some of the controls you will need. So just click on Save in the far top left hand menu.
- Place the cursor in between the <form> element tags, & select “Insert”, “WebPart Zone”. (If the webpart zone icon is greyed out, just save the file again.
- Move the cursor up so that it is above the closing tag of the “</WebPartPages:WebPartZone>”. Create a new line or two.
- Save the file again to activate the Data View icon
- Select “Insert”, click the down arrow under the “Data View” icon at the top menu.
- In the list that appears, you should find the name of the document library that you want to view. Select it & the relevant code will be inserted into your code file.
- Save the file & go back to your SharePoint site.
- Go to “Site Contents” & select “Site Pages”. In the list you will see the ASPX file you have just created. Select it & you should see a page showing your document library with none of the SharePoint menus & page wrappers that you normally see.
- Select the URL of the page from your browser address bar & save it to a txt doc or copy to clipboard.
Actions in the destination site collection…
- Go to your destination site collection. (The SC that you want to display the document library)
- Find the page where you want to see the document library, or create a new page.
- Edit the page
- Go to “Insert”, “Web Part”. Select “Media and Content” from the categories menu. Then select “Page Viewer” from the “Parts” menu. Click Add.
- Within the Page Viewer webpart click on “open the tool pane”
- In the settings window check “Web Page” which is the default & then paste in the URL of the source page that you have just created.
- Click, OK, save the page & you’re done! there are other configuration settings you can adjust such as the size & title etc.
This method of displaying a document library across site collections, of even entire farms is a simple yet quick & easy, non-coding fix to get around the problem. Of coarse, you should also be asking yourself if the document library should be maintained in the location where you want to use it…?
Don’t forget to assign the correct permissions to the source document library else no one will be able to view it.