I have a page layout that intherits from PublishingLayoutPage. In it there is specified a number of fields – the content can be seen here: http://pastebin.com/L4fmc3qb.
However, two of the fields (SendSMS and SendEmail) I only want shown on the edit form on the page, not when it is viewed as a page. How do I hide these fields on the shown page?
Alternatively, is there any way to “inject” these two fields into the page and catch them with an item event? Currently, these fields have been added to the content type that the page makes use of and I use an item event receiver to see if they have been checked, but if there is an alternate way to do this that’s fine as well.
In Sharepoint 2010 you can do this with regular CSS (I’m sure it also works with 2007, but I don’t have a system to test on now) – or check the second part of the answer.
You first have to load a special CSS file for when you are in Edit mode:
If you now have the class e.g.
hideMeFromPageyou could add that to your normal.css:In your edit-mode.css you can now overwrite this property like so:
You only have to add that style to your
<div class="byline hideMeFromPage">and attach a custom edit CSS and you are good to go.Edit: Stupid me… Of course you can also just put your fields within the
EditModePaneltags as described on MSDN or a very nice example page with more kinks about page layouts:Example usage: