Building Content Management System with ASP - Part I
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.
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
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 a lot of effort to build the program, or a copy of the application 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, the user selects a few options, select the Next button, select a few more options, select the Next button, . This will be easier for the user, 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 the user 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 the user 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:
<%
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 a lot of 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 .
If you want 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 the user chooses. A good way to do this is to use a form with checkboxes that contain numbers for each paging tag; for example, if the user 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.
You should read it
- Network basics: Part 1 - Network hardware devices
- Calloc () function in C
- 6 types of SEO duplicate content and how to handle
- 10 effective SEO content checking tools
- How to fix 'The disk selected has an MBR partition table' when installing Windows
- Do you know how to prevent website theft?
- 6 ideas of content that anyone doing marketing should 'steal' from IBM
- What is mixed content? And why does Chrome block it?
- 7 mistakes when developing content as SEO
- What is Unique Content & Why it's Crucial for Your Website?
- How to hide message content on Telegram
- 3 types of most read content on the Internet
Maybe you are interested
Google's parent company is about to acquire a cybersecurity startup for $23 billion Close-up of the world's largest excavator super monster, weighing up to 13,500 tons Alphabet Inc. successfully tested mosquitoes by transplanting viruses into male mosquitoes Google CEO pledged to donate more than $ 800 million to help fight the Covid-19 epidemic How to Teach Yourself to Read The Google corona virus screening website in California has just opened