Table of Contents
The sections below explain building content management system with asp - part i in a clear and practical way. Review the key details, examples, and considerations before applying the information.
With a large site, the news is updated continuously throughout the day, and the content on the site is expanding, such a system will not work. That's when we need a Content Management System
How Building Content Management System with ASP - Part I Works
What is Content Management? When developing content on a site, surely you want your work to be as effortless and easy as possible. If not, you will be bogged down with manual work such as writing HTML code or controlling resource sharing. You need a system that restricts unimportant work and allows you to focus on real content. You need a system that allows users to easily submit articles, the system for you to censor and publicize articles without having to compose a series of HTML pages. Imagine a simple news site with 2 writers updating 2 times a day. Without a Content Management system, the writer will have to download the source code of the current page, add their new message, then upload the page and notify the other person that the page has been updated to avoid being over write. With a large site, the news is updated continuously throughout the day, and the content on the site is expanding, such a system will not work. That's when we need a Content Management System So what part of a good Content Management System includes? Allow writers to easily post to make sure a new record will be created, post a new post that has been posted. Allow editors to easily censor, and publish content Make sure to present content that suits Existing designs These things can be done without interfering with any HTML page and done as easily as possible. Here's how to build such a system using ASP. Posting module There are two ways to build a posting system. You can allow the sender to use their editor or force them to use a Web-based form (with textarea components) to submit content. Obviously, the first way is stronger and more user-friendly, but harder than the following. You must also specify where the content will be placed, often referred to as a file placed on the server.
Written choice? We talked about the first method of posting: let the writer choose their own editor. While this is the best orientation, there are a few compatibility issues that are in place. First, it is the writer's ability to use different word processing programs, and it happens that the person cannot read the text of others. So unless you want to buy licenses for all the different editors that everyone uses, you will have to coordinate compatible versions. The obvious problem is for people to read online articles and articles in plain text format; Word Perfect, Lotus, MS Word,. formats do not work. So first you'll have to convert the text to plain text. Unless you know the binary file format of the document and with many effort to build the program, or a copy of the app installed on the server, you almost can't get the actual content text. event or image in a text file. Therefore, one solution is to ask the writer to convert the text into a form that you can easily manipulate. Many popular text handlers now allow you to 'export as HTML' or 'save as web page'. Or simply, you only receive the HTML or text files sent. However, if the above options are not feasible, you will have to use the second method, forcing the writer to submit content via a web-based form. Backend section Before we really start building the posting system, we need to create a database for the system. The tables we create will contain important information about the content. This is an example database structure for the posting system we are creating:
You can expand the fields you want, but this is a basic framework to get started. Function We will use the wizard-style interface - that is, users selects a few options, select the Next button, select a few more options, select the Next button,. This will be easier for users, and easier. in debugging for developers. How to design a wizard according to the following instructions: - Each step in the wizard is done on a single page. - Any form on a page will point to the same page (in the action section) - Put the script to process the form somewhere on the page, usually at the top of the page - After executing the script, if successful, move users to the next step For example, this is a code from a file named form. asp: <% Code that handles forms Other code . . . If code is successful then Response. Redirect ("form2. asp") End If %> Form components Other form components This is better than using another page to handle the action portion of the form. It allows you to build a wizard-style interface, validate forms easily, and you can easily transfer users to incorrectly entered form entries. Step 1 - Upload to server Assume that the content has been written and compatible text format. How do you have files on the server? There are 2 ways to do it, you can: First/ Let everyone write FTP access so they can upload (upload) files themselves or 2 / Build a form Both methods require special authorization: method 1 requires FTP recording permission, while method 2 requires or logs into the server or grants HTTP write permissions. In addition to the first method, the upload process must be performed separately from the administrative step, and then you will have to give the system administrator the correct file name. The second method will provide you with the correct file name and can be integrated as part of the entire system. If you decide on the second direction, you will need either a COM object or a sufficient amount of knowledge to execute the HTML binary form. Two common COM objects used to upload files are: SA-Fileup ( Http://www. softartisans. com ) ASPUpload ( http://www. persits. com ) But here are two tools that charge a fee. A great free tool is: EZ Site Upload Lite ( http://www. dougdean. com/EZsiteUpLoadSite. htm ) You can create an ASP script to replace the COM object. If you decide to allow writers to submit their posts via the form of the page, then you don't need to know about these COM objects. Instead, the writer must type or cut and paste the article into the textarea field on the form of the page. File uploaded to Server.Next step? If you follow method 2 above, the ASP code needs to know the file name. If not, you'll have to build one more step to ask users about the file name. As soon as you have, you save this file name (and possibly the absolute path of the file) into the database. The following code will enter the file name into the database: #include virtual="/scripts/adovbs. inc" <% Set connFileName = Server. CreateObject ("ADODB. Connection") Set rstFileName = Server. CreateObject ("ADODB. Recordset") ConnArticles. Open "dsn = my_db; Base Data = my_db" StrSQL = "SELECT * FROM tblFile files" RstFileName. Open strSQL, conn FileName, adOpenKeySet, adLockOptimistic RstFileName. AddNew RstFileName. FileName = "blah. HTML" rstFileName. Update IntID = rstFileName. UID RstFileName. Close Set rstFileName = Nothing ConnFileName. Close Set rstFileName = Nothing
%>
You now have the means to access the file later. Before proceeding, you want to know which document to use in the next step. Since the form on this page is self-referenced, you cannot call a Request. Form in the next step to calculate the ID number of the document you just submitted. Instead, at the end of the forwarding URL, attach a querystring with the ID number, use the intID we just created above: Response. Redirect ("step2. asp? ID" & intID) Now when you need information in the next step, simply call Request. Querystring ('ID') and you will know which document you are working on in the previous step. Step 2 - Actions Now that the file has been uploaded and you have the file name, this is the time to do some manipulation with the file. We will use the System Object File to do the job. If you have converted a document from a text format to HTML, there may be a bunch of additional tags that you don't want to appear. For example, Microsoft Word adds a series of XML and CSS tags to convert HTML text into Word documents. Although, these additional tags add a lot to the top of the HTML text, so if you don't plan to convert the text back into Word format, you should delete all these additional commands. This can be done with a series of alternative operations. Const fsoForReading = 1 Dim objFSO Set objFSO = Server. CreateObject ("Scripting FileSystemObject") Set objTextStream = objFSO. OpenText File ("C: Some File. HTML", fsoForReading) Txt File fileContents = objTextStream. ReadAll ObjTextStream. Close If instr (1, txt FilesContents, "", vbTextCompare) then found, delete it Txt FileContents = Replace (txt FileContents, "", "", 1, -1, VbTextCompare) End If Now record the changes just made Const fsoForWriting = 2 Set objTextStream = objFSO. OpenText File ("C: Some File. HTML", fsoForWriting) ObjTextStream. Write (txt FileContents) ObjTextStream. Close set objFSO = Nothing Note that you had to use many loops to remove the junk HTML code in the document. You can also perform any other file operations here, such as, change the file name, replace this text with other text, or add a style sheet.
When needed to split the file into multiple pages, you can also do it here. Here are some ways to do it: Create a table of tblPages pages. The table contains information about the pages in the document. This table will contain data such as: Document ID, tell you which document this page belongs to in tbls File; Page Title, a title for each page and the Page Number, the order of the pages. Add a new field in tbl File, the NumberOfPages field and increment the value of this field each time you add another page. This way, you will know how many pages in each document without having to see how many real files. Name the new files based on the original file. For example, if the original text is test. HTML, the names of pages 2 and 3 are test2. HTML and test3. HTML Analyze files to have a logical division. You can divide the page by number of tags
, or allow users to freely set page breaks. If you follow the second way, you'll have to mark each point that users chooses. A good way to do this is to use a form with checkboxes that contain numbers for each paging tag; for example, if users selects checkbox 2, the page is split in the second paragraph (paraghraph). For each split page, write the content into a new file. This is the most difficult step. Here is the code to execute: Dim CursorFirst, CursorLast StrNextText = file contents Cho m?i v?n b?n trong strNextText Set CursorFirst to beginning of paragraph (ie at position of
) N?u có nhi?u h?n m?t v?n b?n trong strNextText then N?u ?o?n này không ???c ?ánh d?u v?i m?t trang Break, r?i Hãy ??t t?t c? các v?n b?n ??n ngày v?n b?n ? trong bi?n strText Point CursorLast to CursorFirst Else Update the file and tblPages with new page info New file write with strText Clear strText Hãy ??t t?t c? các v?n b?n ??n ngày v?n b?n ? trong bi?n strText Put all v?n b?n sau hi?n th?i v?n b?n trong bi?n phân vùng s?
Point CursorLast to first
Print strNextText End if Else if only one paragraph then Write strText to a file End If You may want to put the function on a separate page. This should start when dividing the original document into multiple pages.
FAQ
What is the main benefit of building content management system with asp - part i?
The main benefit is a clearer understanding of the topic and a practical way to apply the information covered in this guide.
What should I check before using building content management system with asp - part i?
Confirm compatibility, review the required settings, protect important data, and use the latest supported version whenever possible.
What should I do if the result is different?
Repeat the steps carefully, verify permissions and version differences, and consult the product's official support documentation for changes not shown in the article.
Reader Comments 0
Sign in with email or Google to join the discussion.