Customize SharePoint Blog

What I'm trying to do is to replace the default body field with one of custom HTML field for the blog post. Because the customization that we had already done on the HTML rich editor control.

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

  1. Make a copy of OOTB blog site definition and rename the folder to a unique name (i.e. CustomBlog)

  2. There are a few xml files that you can modified, onet.xml (in CustomBlog/Xml) and schema.xml in each list folder.

  3. 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

  1. I added my custom field in the section
  2. 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)
  3. 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:

  1. Add the field to the Posts list
  2. Locate the views with BaseViewID "0" and "7".
  3. 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

Popular posts from this blog

SharePoint 2013 App Details Page Error

SharePoint 2013 - Working with Display Template for Content Search Web Part

SharePoint 2013 Features Information List