Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have a blog site that has allready been deployed to production. Now we need to add a new custom display form to a few of the lists in the blog. For new blogs of this type, it is not a problem as the new forms are added on creation of the blog based on the custom list defintions. But what is the best way to add the forms to the existing blogs? The solution needs to be maintainable, not unghosted forms etc.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can create custom RenderingTemplate, based on standard ListForm rendering template, deploy it to CONTROLTEMPLATES folder, and then programmatically set SPList.ContentTypes[0].EditFormTemplateName, NewFormTemplateName, and DisplayFormTemplateName properties to the name of this template.

This solution is tested and works in production environments, so you can ask for details - I will update the post. To render fields, we are using a custom control, which inherits from ListFieldIterator and overrides Render method, where we use SPContext.Current.FormContext.FieldControlCollection to render fields controls.

I have a test solution which demonstrates this method (you will need to change a hardcoded list url in feature receiver to get it work):

P.S. I consider Sharepoint Designer approach is not acceptable for you for some reasons, though it is the simpliest way here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.