78lro
78lro

Reputation: 1790

How can I change the paragraph formatting in the SharePoint RichHtmlField

In SharePoint we have the the richhtmlfield that allows the user to edit the html content of the page. How can I change the css that is applied when they select H1, H2, Normal etc. from the paragraph formatting button?

I would also like to change the css applied to the tables added to the richhtmlfield, is this possible?

All the best

Upvotes: 0

Views: 3331

Answers (2)

78lro
78lro

Reputation: 1790

As mentioned above, to change the styles that affect the H1, H2 etc, we just need to specify an alternate stylesheet and in it, specify the styles as the are applied in the richhtmlfield control.

The answer for how to change the table formatting layout is to specify a link to the stylesheet that provides the predefined table formats, Sherman posted a good article that pointed me in the right direction for this.

Upvotes: 0

Abs
Abs

Reputation: 1339

Is this a MOSS or WSS site collection that we're talking about? If it's MOSS you can just apply an alternate style sheet that will override the default styling. We put it in a folder in the Style Library in the root of the site collection and specified the the URL to be /Style Library/custom/ourStyles.css.

To get to that setting, from the root of the site collection, go to Site Actions->Site Settings->Modify All Site Settings, then click the Master Page link under the Look and Feel column. The setting you're looking for is at the bottom of the page.

The one gotcha we ran into this approach is that we had to edit the Style Library's permissions so that all users had read access. Otherwise, they didn't see the custom styles, even though those of us who were editing them did.

You can use the same sort of approach with WSS, but it's not as easy to do. You can use the object model to apply an alternate style sheet URL, but I believe you have to touch each different site with your code to do so. You could do it with a PowerShell script or other program, but the idea is the same, you have to loop through the sites, something like this:

SPSite theCollection = new SPSite("http://sitecollectionUrl");  
foreach (SPWeb aWeb in theCollection.AllWebs) {  
   aWeb.AlternateCssUrl = "path to custom style sheet";  
   aWeb.Update();
   aWeb.Dispose();  
}  
theCollection.Dispose();

Upvotes: 2

Related Questions