I'm building out some features for a publishing portal for a client, and I have a requirement to place a Content Editor Webpart on a page and prevent users from deleting, closing, hiding, or moving it. They must only be able to edit the content.
This is really a multi-part question. What's the best approach, and how do I get it to work?
- I tried adding the web part directly to a custom page layout - and the web part renders, but is uneditable. Is there a way to do this and have it be editable?
I'm currently trying to add the web part to the page layout inside a webpart zone and set properties to achieve the desired access:
<WebPartPages:WebPartZone runat="server">
<ZoneTemplate>
<WebPartPages:ContentEditorWebPart>
<WebPart>
<!-- blah blah -->
<AllowEdit>true</AllowEdit>
<AllowRemove>false</AllowRemove>
<AllowClose>false</AllowClose>
<!-- etc -->
</WebPart>
</WebPartPages:ContentEditorWebPart>
</ZoneTemplate>
</WebPartPages:WebPartZone>Right now I'm still building out the page layout using designer, but ultimately it will be deployed as a module feature. Another approach I've seen is to leave the page layout empty but to add the webpart using the
AllUsersWebPartelement to configure the webpart when the feature is enabled. I haven't tried this yet, and it sure would be nice if I could get this to work before I get there because if I have to do it that way, my "compile-edit-test" cycle sure does get long and tedious.