Address: http://www.winu.cn/space-14160-do-blog-id-25923.html
After "using a document library to expand news applications in SharePoint" was issued, many friends received a lot of feedback. This article is intended to inspire others and propose a way to solve the problem, in practical applications, you need to use it flexibly according to the actual situation and needs.
In Article For saving news content, XML is used. However, there are also many disadvantages. For example, the XML file is obtained after the original search. To view the content correctly, you must develop the search. There are many other inconveniences.
Another way to solve this problem is to use a template to save the content directly to the template. Here is a simple example:
First, create a document library to express the classification and layers of the content using the folder and its hierarchy of the document library.
Second, create a content page as a template according to the style of the entire site, and mark it on it, such as <$ title $ >,< $ content $>, these marks indicate the title, author, page views, and body content of the article.
Third, use the editor to create an article.
Fourth, save. When saving, use web. getfileasstring: Get the template string in step 2, replace the tag with the corresponding content, convert the string to byte [], and use folder. files. add to a folder. Note that the saved format must be the same as that of the template, as shown in. aspx or static page. The title, creator, and other content of the document are saved as attributes of the file as a field.
Here, another problem occurs: How can I edit it after saving it? How to display the page views?
The edited question after saving. When creating a template, you can mark the content at the beginning and end. When editing the content, first obtain the string of the file and then search for the start and end tags, then, the content in the intercept is the body, and other headers are taken in the field.
Page views. The difficulty of this problem is that it changes dynamically and cannot be fixed as the text. However, there are also many solutions. The most common method in SPS is to reference controls or Web Components. If the storage format is ASPX page, you can write a usercontrol, then retrieve, display, and update the page views from it. As for the control reference method, you can copy the ascx file to the controltemplates directory of the SPS control, mark it on the page according to the reference method of SPs.
To use this method, you also need to examine performance, security, and other aspects.
Is the page of our recent project:
In this project, we use a similar method for news content, and integrate multiple business systems and single sign-on. Each area block on the page is deployed as a Web part.
time relationship. Please write so much first.