4/02/2008

SharePoint: Web part for a document library folder?

The following is one way to display the folder from a SharePoint library as a web part. While there are other approaches, the goal of the following approach to create this folder display with no code, no custom web parts, no access to the servers and no custom XML or HTML. This approach uses SharePoint Designer to create a new page with a single web part to display the folder. The challenge is not the web part, but displaying just a single folder out of the list. Once the new page has been created you can navigate to the folder and the copy the URL for this page and then use it to display the page in a Page Viewer web part. It of course would be ideal if the library's web part properties included a way to filter by URL or folder.

 

Create a View

  • Go to your document library (Example: Shared Documents)
  • Click Settings menu and select Create View
  • Click Standard View
  • Give the view a name (Example: Folder View)
  • Pick the columns to display - Type (icon linked to document) - Name (linked to document with edit menu)
  • Limit the number of items displayed by expanding "Item Limit" (Example: 10)
  • Click OK to create the view
Add a web part so we can have something to copy to our new page
  • Click Site Actions and Edit Page
  • Click Add a Web Part
  • Add the web part for your library (Example: Shared Documents)
  • From the web part's Edit menu select Modify Shared Web Part
  • Make these changes:
    • Select your newly created view
    • Change the Toolbar Type to None (unless you want the tool bar displayed - for exmple, to allow uploads)
    • Expand Appearance and
    • change Chrome Type to None
  • Click OK
Create the page to display the list
  • Open SharePoint Designer and open your site
  • Scroll down and double-click default.aspx to open your home page - make sure you are displaying the page in Design view (tabs at the bottom of the edit screen)
  • Click the web part that's displaying your new view, right-click and select Copy
  • Click File, New and select ASPX page
  • Rename the page to a useful name such as SharedDocumentsFolderView.aspx
  • Double-click the new page to open it in the editor - make sure you are displaying the page in Design view (tabs at the bottom of the edit screen)
  • Click in the form box and then right-click and select Paste
  • Click File, Save (you can close SharePoint Designer now)
Get the URL to the folder
  • Open a new browser and navigation to the new page. Probably something like: http://moss.litwareinc.com/sites/testsite/SharedDocumentsFolderView.aspx
  • Click on the folder you want displayed. The URL will now look something like:
    http://moss.litwareinc.com/sites/testsite/SharedDocumentsFolderView.aspx?RootFolder=%2fsites%2ftest%2fShared%20Documents%2fsub1 &FolderCTID=&View=%7bE0AECBEA%2d20BB%2d4BC3%2d98BC%2dE65D4ADB9DB1%7d
  • Copy this URL
Add the web part to your home page
  • Return to a browser and display your web site's home page
  • Click Site Actions and Edit Page
  • Delete the web part you added earlier for your library
  • Click Add a Web Part
  • Add the Page Viewer web part
  • From this web part click Edit Shared Web Part
  • Paste the URL to your new custom page in the Link box
  • Change any other properties needed. Most likely are:
    • Appearance -> Title Appearance -> Chrome Type
    • Appearance -> Height Appearance -> Width
    • Advanced -> Title Url (most likely a link to the full library)
    • Advanced -> Description
  • Click OK

8 comments:

concept said...

very helpful.

thanks Mike :)

Anonymous said...

Excellent! I've a question. Can I apply a filter on data displayed in SharedDocumentsFolderView.aspx page?

Anonymous said...

Thanks for this post. Very simple, basic and usable. Saved me lot of time and research.
..Vicky

JDC said...

Thanks Mike!
Amazing but this tis the only page in the web which gives a non coding answer to that challenge!
thxs again...

MIRZA BAIG said...

Can this be used across different sites? Say, I have document library folder under HR site that needs to be displayed on IT site and all sites fall under one site collection.

When I took this approach, designer complains it cannot find the list being referred.

Thoughts?

Mike Smith said...

Mirza,

Yes, but you need to add an ID to the web part's XML. See here: http://techtrainingnotes.blogspot.com/2009/03/sharepoint-one-library-multiple-sites.html

Oliver said...

Hi Mike,

I tried your tip and it works so far that I can display the newly created web page and copy the url to the folder I want to display.
But after deleting the temporarily web part from my home page I receive an error message that an unexpected error had occurred. It seems that the web part that I copied to the new page has a reference to the temporarily web part added to the home page. Have you an idea how I can solve this problem or what I´m missing?

Thanks,
Oliver

Oliver said...

Hi again,

I got it. It seems that the temporarily WepPart creates its own view. And when I delete that WebPart the view is also deleted.

So I looked up the ViewGuid of the original view for my document library and used this id in the Tag WebPartPages as ViewGuid and in the Tag XmLDefinition\View as Name.

After this change it works perfect!

Thanks again,
Oliver

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.