dreamweaver| Static | News system after reading the previous 2 chapters, I believe you have been able to develop such a static page news system. But for a complete news system, these are far from enough. There are many functions, such as: in the news content to insert a picture, to achieve the classification of news, you can choose more templates, of course, you can add a lot of features for your news system, but there is a principle: let users convenient management and operation. Any function is around the user's need to use the habit, remember to remember!
Perhaps you will ask, why do we have to do these news classification, templates, such as multiple election cumbersome things? Xiao Tian in the beginning of the Web application development, and your idea, but also to do their own very easy to meet! But customer requirements are often not based on your ideas, they are often in the process after the completion or development of the later, put forward some other you have a headache requirements, so that you want to change your program, dynamic surgery. So in the early days to understand the customer requirements and use habits, and can think of the changes they may propose. For example: Today your news system is done, the customer suddenly proposed to more than one news column, and the style to be different!! Is that when you stare at him with big eyes? Or find a drill in the hole? Or the last dingy back to change your program!!!
Let's start with some of the features mentioned above. First look at the news classification.
1, the first is the database design, we want to add a table in the original database: T_type, as shown:
Enter a few categories in the inside, as shown in the figure:
Open the original table t_news, add a new field in the n_type_id (used to correspond to the foreign keyword of the news classification), as shown in the figure:
If this time, your news system has content, but also in the original data content to write this category ID, for convenience, or delete the original news records!
2, modify the News Add Page add.asp page. Open add.asp page, we insert a table row above the news content, write the "news type" in the left column, insert a list list item in the right column, name= "News_type", as shown in figure:
Then, we add a recordset for the news classification, as shown in figure:
Next we will put the recordset in the list form, select the list form, and open the server behaviors-->dynamic elements-->dynameic List/menu, as shown in the figure:
Click OK, OK, the news type Recordset is already in the list. Save add.asp,ok! Now
3, modify the Save News page save.asp page. This page we just change 2 code is good, because the addition of news content to the database code is from the add.asp page copy past, we do, no special circumstances, the code in the Add.asp page, and then the entire copy to the Save.asp page is good. Now we have to change the save.asp page. Open the Code window for the Save.asp page and locate the following code:
MM_fieldsStr = "n_title|value| n_content|value| n_filename|value|
n_filepath|value| N_date|value "
MM_columnsStr = "N_title| ', none, ' | N_content| ', none, ' |
N_filename| ', none, ' | N_filepath| ', none, ' | N_date| ', None,null '
To be replaced by:
MM_fieldsStr = "n_title|value| news_type|value| n_content|value|
n_filename|value| n_filepath|value| N_date|value "
MM_columnsStr = "N_title| ', none, ' | n_type_id|none,none,null|
N_content| ', none, ' | N_filename| ', none, ' |
N_filepath| ', none, ' | N_date| ', None,null '
We can change inside, add more | News_type|value| (This represents the value passed from the table Single-name to the value of News_type) and | N_type_id|none,none,null (this means adding to the data field n_type_id) to save the save.asp page.
Ps:ud Insert data is done using INSERT into, you see, Take the Request.Form value is the table item name and so on group number group, then uses the function split () to separate, then takes the request the value, this does is for the software use convenient, everybody does adds the data not to do so oh! To Faint, O:
4, modify the News Browsing page browse.asp page. This page we learn to associate news records with news types, where SQL statements are applied. Open browse.asp page, reopen Recordset Rsbrowse, click Advanced ... (advanced), modify the original SQL statement, as shown in figure:
Look, here's the SQL statement: INNER JOIN .... On ..... Associate two tables, click OK. We see that the original Recordset has changed, as shown in figure:
Then we add the type of news behind the original news headline, as shown in figure:
Browsing, is not the type of news!! (Classification of the changes and so on here will not be repeated, everyone to do their own action)
PS: Here we see Adding news, the news type that inserts the T_news table is the T_type ID value. You might ask, why not just insert the value of T_type's t_typename? In this case, the call will not be associated with 2 tables! But there is a problem, if you suddenly want to change the name of the news classification, then it is not to change all news records in the news classification name! That's too ... (The little field in front of the computer has passed out)
OK, the simple News classification is also available, let's look at the multiple selection of templates. This section is simpler, and some are similar to the news classification above.
1, still is the data modification. Open the original table t_example, we add a new field E_type, as shown in the figure:
Fill in a category in the Data window, as shown in figure:
2, modify the News add page add.asp. Add a list (name= "Example_type") of the template category to the list above to add a news category, and put the recordset in the list (Value=id). This is not a detailed talk here.
3, Save the News page save.asp page. This page is mainly based on the add.asp list (name= "Example_type") passed over the value of the corresponding template records. As shown in figure:
Save the page, now the template has more than one choice, we can do a few more templates to play.
Many netizens ask how to insert pictures, hyperlinks and so on in the news. The more conventional method is to use UBB code, like we insert pictures in forum articles, such as:, here you need to write a section of UBB Code, small field will not write, for everyone to write a good, click here to download.
Remember that part of our previous Save.asp page that allows the news system to display paragraphs and spaces properly, now open it and find it:
<script Runat=server language=vbscript>
function DoWhiteSpace (str)
DoWhiteSpace = replace ((replace (str, VBCRLF, <br>)), Chr (+) &CHR (32), "")
End Function
</SCRIPT>
We copy the downloaded page ubbcode.asp to the News system directory and replace the above function with the usual statement:
<!--#include file= "ubbcode.asp"-->
Then find the function statement that was originally invoked below:
N_content=dowhitespace (Request.Form ("N_content"))
To be replaced by:
N_content=ubbcode (Request.Form ("N_content"))
Similarly, the News update page updata_save.asp also want the same change, OK, now try to add a news, content written on:
Htt://www.guitarsky.com, after success, browse to see if there is a hyperlink!!
OK, now our asp2htm news system has been gradually improved, of course, you should be able to think of more functions to improve it, small field is just a start, so that we can better use the UD development of ASP system. Xiao Tian is a heartfelt favorite UD this software, but if you rely too much on it, you will feel that its function is more and more can not adapt to your requirements, Xiao Tian to tell you are, to learn more ASP (now everyone should start to learn asp.net) knowledge! The software is dead, you are not Oh!!
Previous Page