When you are a beginner, the program can be barely written, but if you perform a website page revision, all source programs will undergo a transplant. The manpower and energy spent on this is exhausted, and even the loss is not worth the effort and all previous efforts are wasted.
So, I dreamed of such a large piece of program code becoming a few simple characters instead, so that as long as I design the page and insert the function, it would be OK. In fact, this is also simple. Just make the program code that implements this function into a subroutine and then call the home page.
Many times, in blog China, you will choose many templates, and may even design them yourself; or major webmasters who use Zhu Feifei BLOG have changed their sites differently... We all attribute these to the ASP's template function.
Then I will borrow flowers to offer Buddha and use the template to analyze it to give it to all friends.
First of all, if the template needs to be modified online, the template code should be saved using the database.
The so-called template is a standard HTML code designed and completed, where the functions that need to be implemented by the program will be replaced by special strings. However, these special strings need to be compiled into corresponding functions when displayed.
1. Design database testmb.mdb
Create a new table moban: field m_id (auto number, main keyword); field m_html (remark type)
2. Assume that the first template content code
Copy the following code into the m_html field
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>testmb</title> </head> <body leftmargin="0" topmargin="0"> <table cellpadding="5" cellpacing="2"> <tr align="right" bgcolor="#CCCCCC"> <td colspan="2">$cntop$</td> </tr> <tr valign="top"> <td bgcolor="#e5e5e5">$cnleft$</td> <td bgcolor="#f3f3f3">$cnright$</td> </tr> </table> </body> </html> |
Note $cntop$, $cnleft$, $cnright$, they will implement certain specific program functions.
3. Create a database connection file conn.asp
<% set conn= Server.CreateObject("ADODB.Connection") connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("testmb.mdb") conn.Open connstr %> |
4. Create the library file lib.asp required for special string conversion
The main function of this file is to make ASP programs that implement certain functions into word programs for easy call.