Thursday, 12 March 2009

Storing Site Metadata - The Easy Way

There are many scenarios where you might want to store metadata on a site - for example, if you are creating project team sites, you might want to attach the project reference number, manager, RAG status, etc. If you are into development, you can do this by writing to the site property bag, but if you're not, the easiest way I have found is to create a custom list on the site and add your site information to the first item in the list.

This is very easy to do, and of course users will be able to add the information using the standard list edit form in the UI and you can assign appropriate permissions for specific people to add this information to the site.

There is one request I have had from users though, and that is to show the metadata in a Web Part on the home page of each site and allow new sites to be created from a template which also show the metadata on the home page by default. Whilst not the biggest fan of SharePoint Designer, it does allow you to do this quite easily:

1. Create your list on the site (I have called it Project Information for this example)

2. Create the columns to contain the metadata that you wish to store

3. Add at least one item to the list - I usually populate it by populating the Title column value with "Complete these details for this project by clicking "Edit Project Information" in the left-hand navigation" and creating a link to the EditForm.aspx file in the Quick Launch.

4. Create a new Web Part page on the site as a temporary home for your Web Part.

5. Edit the Web Part page in SharePoint Designer, click Insert > SharePoint Controls > Custom List Form.

6. Choose your custom list in the drop-down box, select the "Display Item Form" and untick the standard toolbar option.

7. Delete any unwanted cells and rows from the table, and get it looking how you want it.

8. Save the page (this will mark the page as customised, but you are deleting later anyway).

9. Go to the Web Part page in the browser and export the Web Part to a file.

10. Go to the default.aspx file on the site and import the Web Part from the saved file.

11. Delete the temporary Web Part page (this was created to avoid you having to edit the default.aspx page - thus, marking it as a customised page).

12. Save the site as a template, remembering to tick the "Include Content" option so that the first item in the custom list is stored in the template.

13. Create a new site using the template - the site metadata will now be present on the home page.