开发者

Sharepoint: Change page layout and content type for specific page

I have a page layout in a solution I have deployed. The page layout also has a custom content type associated.

I wish to update this page layout and content type, but only for a specific place on the site. The reason is that for important "operation updates" we want the ability to send out SMS's to subscribed users (a built-in feature of Sharepoint for lists) as well as e-m开发者_StackOverflow社区ail them.

The way this works is that I wish to add a boolean field that decides whether SMS's are send or not, and a field to put in e-mail adresses you want notified of the message.

My approach so far has been:

  • Create an event receiver that checks whether the fields are selected / filled out and do the actual sending.
  • Alter the layout page with the 2 new fields.
  • Alter the content type with the 2 new fields.

However, I am afraid of the complications for the rest of the site. For now, future uses of the page layout is not a concern, just the existing uses.

I know that updating a content type through XML definitions does not happen automatically, so on that side I'm safe, but how do I keep the layout page "contained" to the specific page in question?

EDIT: How do I show the two fields only when editing the page, not when showing it? Currently, my development site shows the edit form just right, but when I go to show the page it shows "yes" where boolean field is located and any e-mail adresses entered where the e-mail field.


Are you sure the page layout is associated with the content type, and that it's not a page that is associated with the content type?

If you want fields to be automatically added, you can:

  1. Create a custom rendering template that is used by the New/Edit/Display forms for your list (http://weblogs.asp.net/sharadkumar/archive/2008/07/07/how-to-customize-rendering-of-sharepoint-list-form-fields-part-1.aspx)

  2. Create a custom ListFieldIterator (or use the default one) that will automatically pick up new fields in your content type (http://msdn.microsoft.com/en-us/library/aa543922.aspx)

  3. Use code in a DLL to iterate through your content type's fields and thus create the necessary controls for your page all in code. If you use FieldControls (http://msdn.microsoft.com/en-us/library/dd571480.aspx), it will automatically create the default template rendering for the field (i.e., it will display radio buttons, drop down boxes, etc., as defined by the fields in the content type).

In your EDIT, when you say 'when editing the page', I'm assuming you mean 'when viewing the edit page for the list', and not 'when editing the page definition in Sharepoint Designer'.

Assuming that assumption is accurate, you can have the edit page for the list show something completely different from the view page for the list (and from the new page for the list). The pages are, by default, defined completely separately, and are edited completely separately. However, if you are using something (such as the ListFieldIterator) that automatically picks up the list of fields for the content type, you can create a custom Field Control for the fields you want to hide and have the view template for the field control set to display nothing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜