Multi-language and custom CSS

Source: Internet
Author: User

Recently, a Sharepoint 2010 project found that after the English and Japanese language packs are installed, the system returns an exception when selecting the alternate language in the language settings of the website settings, websites that contain custom Style Sheets (CSS) do not support multiple languages.

I have never paid too much attention to what is "custom CSS". After some research, I found the problem:

When a website references CSS, it references files in the layouts directory (for example,/_ layouts/2052/styles/corev4.css). This CSS is obviously shared across the server farm; however, the website references the/_ styles/corev4.css in the website (this is not a virtual path, it is a directory in the website, it exists in the Database) -- This is the so-called "Custom CSS ". You think, the CSS in layouts is divided by language. Different CSS is referenced in different languages, and they are all the same in _ styles, of course not, so the multi-language quit.

Then the next question is, how does this custom CSS appear? How to restore to non-custom CSS? How should I modify the default CSS? One by one.

1. How does custom CSS appear?

In fact, the custom CSS emerged from SharePoint 2007, but since there was no such multi-language mechanism as 2010 at that time, this problem was not highlighted.

After some investigation, we found that this was because our artist used SharePoint designer to change CSS. Open a page in SPD, and several classes will be listed on the page. When we press and hold the ctrl key to click these CSS, the corresponding CSS file editing will be opened:

When we save this CSS:

Do you see "Custom Style Sheets? It's from here. Once "yes" is clicked, Sharepoint will save the CSS file corresponding to layouts to the _ styles directory of the website (if this directory was not found before, it will automatically create one, note that this is a directory, not a document library ). In fact, this is very reasonable. It is not because you want to modify a CSS in the page, it will affect all the websites on the server farm, right? Therefore, this process is similar to the unghost process.

Of course, using the object model can also easily complete this process. You only need one sentence:

   1: spWeb.CustomizeCss("corev4.css");

(In fact, I used this method to flip the SDK, and then used reflector to determine that the multi-language was caused by this)

2. How to restore to non-custom CSS?

Now that you know the custom method, you have a clue about restoration. Write a console directly and use the same sentence:

   1: spWeb.RevertCss("corev4.css");

3. How should I customize CSS?

The standard practice is certainly not to modify the CSS files under layouts (unless you want to change the website throughout the server ). You can put the place you want to change to a CSS and set it to the backup CSS of the website. For details, see:

The above interface is in the website settings-master page (not the master page under the database category), this is a link that appears only when the publishing function is enabled. If the release function is not enabled, go directly to the "/_ layouts/changesitemasterpage. aspx" Page (I have not tried it), or use a program to modify it. This alternative CSS will be automatically placed after the system's default CSS file for reference, so it will overwrite the default CSS style (some of the default styles are marked with "! Important ", which should be added if you want to overwrite this setting in custom CSS)

You can also modify the master page to use the SharePoint: cssregistration control to reference the system CSS Reference (SharePoint: csslink and SharePoint: theme in the master page, in this way, the switch can be automatically performed based on different languages (you can write your own msdn or Google Code)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.