Something written N years ago. Pull it back online now. At that time, I gave up on the second plan. Fast. By studying. NET and studying Regular Expressions in depth, we now have a deep understanding of it. And other. Net versions. Write two. Preface: Keep writing this thing intermittently. However, there are few articles in this regard on the Internet, so here we will talk about the experience and ideas in the personal production process for your reference only. please correct me if you have any mistakes. The intention is to encourage others who wish to share their experiences in this field. I will explain my personal thoughts here. I am sorry for the poor text expression skills. The original intention of designing this system is to separate the program from the interface. When creating a website, you only need to design a set of interfaces and add the labels provided by the system to the template import system, in addition, it has a high degree of freedom in content organization and interface definition. The producer does not need to access any programs. By installing plug-ins, In the DW visual editing environment, inserting template tags is as easy as inserting HTML code. See the following figure. <cms:loop target='sort' name='allsort' cols='' rows='0'> <table width="400" border="0" cellspacing="1" cellpadding="0" style="border: 1px solid #999999;"> <tr> <td bgcolor="#CCCCCC"><a href="<cms:urlsort>"><cms:sortname></a></td> </tr> <tr> <td height="1" bgcolor="#666666"></td> </tr> <tr> <td bgcolor="#CCCCCC"> <cms:loop taget='article' cols='10' name='articel'> ·<a href="<cms:urltitle>"><cms:title lenth='20'></a><font color="#666666"><cms:date></font><br> </cms:loop name='articel'> </td> </tr> </table> </cms:loop name='allsort'> This is a template file that displays 10 records in all subtopics and subtopics cyclically. <CMS: ***> is the tag provided by the system. Based on these labels The file generation result is as follows: We often see ***. com/news/2004/06/08/2314342 .html Similar websites, This is the static html page generated by the website's background management program based on the database class. I don't need to mention its advantages. The purpose is to use ASP to dynamically generate webpage files in HTML and other formats using the page content. The main method used here is to replace it. That is, the program replaces the defined mark in the inventory file with the specific Record Content in the database and generates the corresponding page file. The difficulty of template replacement lies in loops and nested loops. (For example, a common 2-level page loops all the subtopics of the current topic, 10 new records are circulating under each topic, and some have 2-3 columns circulating horizontally in each row) and parameter transfer and analysis in the loop. The rest is just a replace, which is summarized by writing code once. Here, I will divide the page creation process into the following steps. A large flowchart is drawn here. The first step is to create a queue. 1) What is used to create a queue is to tell the creation program what files I need to create. Then the program creates files one by one based on the set of created queues, so that the line of generated files is very object-oriented. this is because we may manage the following actions: create all columns and articles, create a topic, create a topic and article, create an article, and create a selected topic or article. after the concept of queue is introduced, we only need to combine the content IDs to be created and hand them over to the function itself. you do not need to know what the behavior is. if I call a function after adding a record and send the topic path and Article ID of the article, the program will create corresponding files one by one based on these numbers. so there will be a lot of room for expansion in the future. for example, 21,22, 23,-201 (these numbers are mainly column and Article ID). Why is there a negative number? Read down. 2) After receiving the queue set, we should find the relevant parameters of the record in the database based on the ID one by one to create the page. Here, a file is created every time the page is refreshed automatically. It should be unscientific for the one-time program to occupy a large amount of CPU for a long time if many files are to be created at a time, and it is likely that the script times out. Here we will post two code snippets for further explanation. <! -- # Include file = "_ INC/Conn. ASP "--> const spacetime = 8 dim FSO, WTO, fder, SERVER_NAME dbopen () set FSO = server. createobject ("scripting. fileSystemObject ") Call Main () set FSO = nothing dbclose () * Subs *******'**** * ************* dim global_childs, global_pagecutnum 'Global variables, used by morethan one function sub main () dim rsprv, sqlprv, J, K, come dim alignment, cstep, steps, Steparr, currentstep, prvpagecutnum global_pagecutnum = request ("page") cstep = request ("cstep") Steps = request ("Steps") alignment = request ("queue ") 'Control the progress of the previous page display if steps <> 0 then dim percent = int (cstep/steps * 100) response. write ("<SCRIPT> parent. percent. width = '"& percent &" %' </SCRIPT> ") end if' # interrupt? 'Determine whether the creation process is complete if int (cstep) = int (Steps) and steps <> "" Then printinfo ("<font color = Red> All are created: </font> Create a Web file together "& SESSION (" totalfiles ") &"; time consumed "& formatnumber (timer ()-session (" starttime ") *, 3) & "millisecond") session ("totalfiles") = "" Session ("starttime") = "" Exit sub end if 'didn't receive the created queue for the first time, by default, all content is created. If alignment = "" Then call alignment_all () 'is created to get the current progress and the value if steps = "" then steps = ubound (steparr) + 1 'run once only if SESSION ("totalfiles") = "" Then SESSION ("totalfiles") = ubound (steparr) currentstep = steparr (cstep) set steparr = nothing: Create a topic based on the ID value greater than 0. If the negative value is greater than 0, create the dim sortid, forder, storepath, parentpath, templet if int (currentstep)> -1 then set rsprv = Conn. execute ("select * from [" & op_table_class & "] Where sortid =" & currentstep) sortid = rsprv ("sortid") templet = rsprv ("templet ") forder = rsprv ("fordername") the sort's storepath just like it's fordername global_childs = rsprv ("Childs") parentpath = rsprv ("parentpath") rsremove (rsprv) if global_pagecutnum = "" Then call creat_forders (forder) 'creates an object, calls the primary function of creating a file, and obtains the parameter dim mycreat, pagecutnum set mycreat = new creat mycreat. sortid = sortid mycreat. templet = templet mycreat. storepath = forder mycreat. parentpath = parentpath mycreat. reg = "<CMS: loop>" 'the loop function is currently defined only in non-Ultimate pages. creatclass () prvpagecutnum = mycreat. pagecutnum 'determine whether to enter the paging process set mycreat = Nothing else' if it is less than 0: Create the article page dim templetsun, id' the article Id record is negative, convert to positive number id = int (currentstep) *-1 Set rsprv = Conn. execute ("select. ID, S. templetsun from ["& op_table_article &"] A inner join ["& op_table_class &"] s on S. sortid =. sortid where. id = "& ID) templetsun = rsprv (" templetsun ") rsremove (rsprv) Call creatfinal (ID, templetsun) end if '# interrupt' parameter is passed to the next response creation. write ("<body onUnload = 'Creating. submit () '> ") response. write ("<form method = 'post' name = 'creating'> <input type = 'den den 'name = 'come 'value ='" & come & "'> <Input type = 'ddden 'name = 'cstep' value = '"& cstep &"'> <input name = 'steps' type = 'ddd' value = '"& steps &" '> <input type = 'ddden' name = 'page' value = '"& prvpagecutnum &"'> <input type = 'ddden 'name = 'queue 'value = '" & alignment & "'> </form> ") response. write ("<meta http-equiv = 'refresh' content =" & spacetime & "; url = 'lib _ creat. ASP '> ") At the end of the Code, some HTML content is output here. First look at response. Write ("<meta http-equiv = 'refresh' content =" & spacetime & "; url = 'lib _ creat. asp '> ") That is, the HTML code of the page is automatically refreshed after the program runs to the end. Look at response. Write ("<body onUnload = 'Creating. Submit () '> ") This defines the form that can be passed through querystring when the page is submitted during uninstallation. However, in the past, it seems that the maximum amount of data that Yi can only transmit is kb, which cannot be remembered. Therefore, the Form POST method is used for submission. If the queue is too long to be created, for example, if my website has 10 large and small columns with 1000 articles, one day I have a new template and want to recreate all the content, it is unlikely that an execution is completed. This is like a relay race. Create one file and one file. The other advantage is that you can return the current progress and specific information in the creation process to the user at the same time (which can be viewed later). For example, if a tag definition error occurs in a template, as a result, the page fails to be created. The information should be fed back to the user. Another point is that we have seen some similar systems in the past. We also refresh the page, but the page keeps refreshing, which causes the screen to flash continuously. So here we use creat. iframe with a long width of 0 in ASP connects to the lib_creat.asp file. To solve the problem of page blinking. Summary: the ID of the file to be created forms a queue which is generated by the creation function one by one. The number in the queue indicates that the column ID is negative, indicating the Article ID. To ensure resource usage, access this function every time you refresh the page to generate a file. |