Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top