Customize SharePoint Blog
In general, there are 2 things that can be done 1) site definition, and 2) feature
The first thing that I tried was creating a custom blog site definition from the OOTB site defintion, since modifying OOTB files is always against the best practice and can avoid warranty in some cases.
The MOSS OOTB blog site definition is located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\Blog.
Custom Blog Site Definision
- Make a copy of OOTB blog site definition and rename the folder to a unique name (i.e. CustomBlog)
- There are a few xml files that you can modified, onet.xml (in CustomBlog/Xml) and schema.xml in each list folder.
- After update the site definition xml files. You'll have to do an iisreset before the changes will take effect.
I have modified the following places for the schema.xml for the Posts list
- I added my custom field in the
section - I updated the
element for and View BaseViewID="7" ...> to display my custom body field instead of the default Body field. (Notes: BaseViewID 0 is the default view used for the blog default page and BaseViewID 7 is the default view used for editing the blog) - I also updated the
element to include my custom field.
I also updated the onet.xml file so that when it created the first welcome blog, it puts the content into my custom body field instead.
This doesn't work .... My custom field does get added to the list and display correctly on all the views. However, the custom field does not show up in post edit form. I tried add the field manually through the web UI and it does show up in the edit form. I compared the field schema and I can't find any difference. And finally .... I gave up.
I moved on to use Feature and do everything in code when the feature is activated. I can either staple the feature or just activate the feature directly in the custom site definition. In the code, I basically did the following:
- Add the field to the Posts list
- Locate the views with BaseViewID "0" and "7".
- Update the ViewBody and ViewFields for those view.
The object model approach works and now I can use my custom field for the body of the blog post.
If anyone has any idea why the site definition approach doesn't work, I'll be glad to hear.
Thanks,
Comments