Tuesday, March 25, 2014

SharePoint: Adding hyperlinks to document libraries

Sometimes you have external content that you would like to make available from your document library without uploading a file. Examples include documents in other SharePoint sites or libraries, and even links to other web pages including SharePoint pages and external web sites.

Turns out SharePoint already has this built-in, just well hidden. There is a built-in Content Type called "Link to a Document". Just add this to your library and then just click the "New" dropdown and select "Link to a Document"! It will simply ask you for a document name and url. You can supply a URL to anything that starts with "http://", including both SharePoint documents and external web pages. It does not support a link to a network share such as "\\myfileserver\folder1\somedoc.doc".
  1. Display your library (Example: Shared Documents)
  2. Click Settings and Library Settings
  3. Click Advanced Settings
  4. Check "Allow management of content types" and then OK
  5. In the Settings page scroll down to Content Types and click "Add from existing site content types"
  6. Select "Link to a Document", click Add and then Click OK
  7. Go back to your library and click the New dropdown and select "Link to a Document"
  8. Enter a display name (Document Name) and the URL (must start with http://) and click OK
So how does it work? The Content Type has a template that is an ASPX page that contains a server side control named SharePoint:UrlRedirector. When this page is rendered it simply redirects to the address listed in the items URL property. Also experiment with adding these built-in content types to your library:
  • Basic Page
  • Web Part Page
  • Dublin Core Columns (Do a web or wikipedia.com search for "Dublin Core")
  • Picture
You can also add customized folders to the New dropdown. See here. Need to add custom columns / meta data to any of the above? Just create a new Content Type based on one of the above and add it to your library. See here.

Note:
First Enabled "SharePoint Server Publishing Infrastructure" features under in Site Action --> Site Settings --> Site Collection Administration

No comments: