The Content Editor Web Part (CEWP) allows you to add text, html, scripts or styles to a SharePoint page. Its versatility makes it a favorite among Web designers.
The fpweb.net site offers a tutorial on how to add a CEWP to a page:
http://www.fpweb.net/sharepoint-tutorials/ContentEditorWebPart.asp
The CEWP has two edit options:
– Rich Text Editor: as it says, allows you to add formatted text.
– Source Editor: this is a more powerful option, allowing you to add html, scripts or styles.
Note that the CEWP is not the only Web Part to allow you to add html to your pages. In some cases you may also consider the Form Web Part or the Page Viewer Web Part.
Looking for examples?
You’ll find on the Web many examples of how to use the CEWP. There’s even a whole site dedicated to it:
http://www.contenteditorwebpart.com/default.aspx
Many scripts were introduced for SharePoint 2003, usually they’ll also work in SharePoint 2007 (after all, they just use JavaScript). This is not the case for styles, as some ids and class names have changed from SharePoint 2003 to SharePoint 2007.
If you add scripts or styles, you’ll usually choose to hide the CEWP (check the “Hidden” box under Layout).
If you break your Web page…
When playing with the CEWP, you run the risk of adding bad code that will break your page. SharePoint will then throw out an error message, without offering any way to undo your changes.
If this happens to you, here is a useful trick: append the “?contents=1” querystring to your URL. It will give you access to the maintenance page, where you’ll be able to get rid of the faulty Web part.
For example, if you inadvertently break this page:
http://ThisServer.com/sites/ThisSite/ThisLibrary/allitems.aspx
Enter:
http://ThisServer.com/sites/ThisSite/ThisLibrary/allitems.aspx?contents=1
A trick to edit Web Part pages
On some pages, the edit option is not available or is grayed out. This is for example the case for the edit form of a list.
The workaround here is to append the “?ToolPaneView=2” querystring to your URL, which will switch your page to edit mode. Note that it seems to be unsupported by Microsoft, though I haven’t read an official confirmation.
For example, if you want to edit:
http://ThisServer.com/sites/ThisSite/Lists/ThisList/editform.aspx
Enter:
http://ThisServer.com/sites/ThisSite/Lists/ThisList/editform.aspx?ToolPaneView=2
Nice trick! Wish I had known this before I started monkeying with code! =)
I put together a quick little Javascript bookmarklet to automate this.
Check it out – http://mr.ben.bradley.googlepages.com/jsredir-bkmklt.html
When you’re looking at a page you want to edit, just click the bookmark and you’ll be presented with the same page, but with “?ToolPaneView=2” enabled.
Thanks for the info Ben!
Pingback: No assembly required « Path to SharePoint
Pingback: Adding extra content to a list form - From SharePoint with love
Pingback: The Content Editor Web Part « Microsoft Technology, .Net, BizTalk, Sharepoint & etc.
The whole CEWP + JS trick is excellent. However, I find that it doesn’t work for lookup columns. In designing the calculated expression, lookup columns aren’t listed. I know the MS docs list this as a limitation of WSS 3.0 but is there a workaround so that we can do work of a lookup column?
A workaround for columns of type lookup, ID, rich text, etc. is to use a workflow to copy the values in a column of type text.
Pingback: Image rotator: build your own! « Path to SharePoint
Pingback: The Content Query Web Part « Path to SharePoint
Pingback: Using calculated columns to write HTML « Path to SharePoint | Rickey Whitworths Blog
Pingback: Content Editor Web Part - surpoint 2
Hello,
One of my friend told me that if you hide the CWEP, the script won’t apply anymore. Is that right ?
thanks
That is not correct, the script will still apply.
Hi All,
I have a Telerik RadEditor on the sharepoint and iam unable to edit the webpart. How can i edit the webpart, please suggest.
The “modify webpart option ” doesn’t appear eventhough i have clicked on “edit page” from site actions.
IMP:- the webpat uses 3 images all of which are of size 567X113 pixels.
Awaiting reply
Well, obviously you should contact Telerik…
Pingback: Tasks Lists Roll-up beta, available for download « Path to SharePoint
Pingback: About Scripts, Web Parts and Urban Myths « Path to SharePoint
Pingback: Openen van URL’s in een nieuwe browser in SharePoint « Joost van Lier's Blog
awsome. you save me so much time.
Thank you
I love the “?ToolPaneView=2” querystring to edit forms…do you have a quick JS code to be able to format fields like phone numbers?
Hi!
Very good the post. I have a question i did it and it is works fine, but… when i put a group by in the list it is not working? Do you know the solution?
Thanks
Pingback: Bridging the gap between the users and IT « Path to SharePoint
Thanks for the inspriation…
I did something similar with jquery. In my calcuated column, I added a ‘calculated-column’ class to my wrapping div to find it easier.
//change html escaped text from calulated column to the innerHTML
$(‘.ms-vb2’).each(function (index) {
if (this.innerText.indexOf(‘calculated-column’) > 0) {
this.innerHTML = this.innerText;
}
});
Thanks for sharing Peter!
I believe 1 of your ads triggered my internet browser to resize, you may want to put that on your blacklist.
It’s actually a great and helpful piece of info. I’m happy that you just shared this helpful info with us. Please stay us up to date like this. Thanks for sharing.
Hi there colleagues, its enormous article on the topic of tutoringand completely explained, keep it up all the time.
Your method of describing the whole thing in this post is genuinely nice,
every one can without difficulty understand it, Thanks a lot.
or: Appearance, Chrome Type:None
The best as well as the model of promotions commonly
are different while using backer also, the model of keepsake
provided. Once connected, you can easily transfer videos and music to your system
from your Media Center PC, chat with friends, play games via Xbox Live and more, all without the clutter of wires.
This revolutionary latest smart cell phone perfectly brings entertainment, work,
and family together all in one place with Live Tiles.