Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: Template to HTML file


Message #1 by "john hamman" <johnhamman@h...> on Fri, 23 Nov 2001 23:46:58
Ok im interested in building a template system that pulls from a template 

(dynamic : user pics a choice tmplA.tmp,tmplB.tmp,tmplC.tmp) and it will 

create from the template a static page from the template. What are some 

steps for this. so far i cant find anything. All i find is pulling from a 

template to form a dynamic single page. I would like to make many static 

pages. In other words every time someone fills out the form, it will 

create a new static page on the server. 

thanks

john
Message #2 by "Jason Salas" <jason@k...> on Sat, 24 Nov 2001 11:11:07 +1000
Good question.



To choose between multiple page ranges, you would eed to have a drop-down

menu in a form containing your choices.  Then on the page which processes

your script, you would need to employ a SELECT CASE statement, which would

contain the specific code to assemble that page.  It might be a long script,

but it'll work.



For example, your form in PAGE1.ASP has a drop-down menu with a NAME

attribute of "TYPEOFPAGE", with tmplA, tmplB, tmplC, and tmplD as page

layout templates.  It also has a textfield with a NAME attribute of

"FILENAME" so you could name your files when saving them to to server:



<html><body>

<form method="POST" action="page2.asp">

   <p><select size="1" name="TYPEOFPAGE">

    <option value="tmplA">TemplateA</option>

    <option value="tmplB">TemplateB</option>

    <option value="tmplC">TemplateC</option>

    <option value="tmplD">TemplateD</option>

  </select></p>

   <p><input type="text" name="FILENAME" size="20"></p>

   <p><input type="submit" value="Submit"></p>

</form>

</body></html>





...this would pass the value onto PAGE2.asp, which would selectively render

a page, based on the template specified in the form:





<%



Select Case Request.Form("typeofpage")



Case "tmplA"

       ' Write the HTML for your Template A page here using Response.Write

and the FSO to create your text file

       Dim FSOa, myPagea

       Set FSOa = CreateObject("Scripting.FileSystemObject")

       Set myPagea = FSO.CreateTextFile("c:\inetpub\wwwroot\" &

Request.Form("FILENAME") & ".html",True,False)

       myPagea.Write("<html><head><title>This is my title from Template

A</title><body><h1>Hello, world!...more info to follow</h1></body></html>")



       Response.Write("You have successfully created a page from Template

A!")

       Set myPagea = nothing

       Set FSOa = nothing



Case "tmplB"

      ' Write the HTML for your Template B page here using Response.Write

and the FSO to create your text file

       Dim FSOb, myPageb

       Set FSOb = CreateObject("Scripting.FileSystemObject")

       Set myPageb = FSO.CreateTextFile("c:\inetpub\wwwroot\" &

Request.Form("FILENAME") & ".html",True,False)

       myPageb.Write("<html><head><title>This is my title from Template

B</title><body><h1>Hello, world!...more info to follow</h1></body></html>")



       Response.Write("You have successfully created a page from Template

B!")

       Set myPageb = nothing

       Set FSOb = nothing



Case "tmplC"

      ' Write the HTML for your Template C page here using Response.Write

and the FSO to create your text file

       Dim FSOc, myPagec

       Set FSOc = CreateObject("Scripting.FileSystemObject")

       Set myPagec = FSO.CreateTextFile("c:\inetpub\wwwroot\" &

Request.Form("FILENAME") & ".html",True,False)

       myPagec.Write("<html><head><title>This is my title from Template

C</title><body><h1>Hello, world!...more info to follow</h1></body></html>")



       Response.Write("You have successfully created a page from Template

C!")

       Set myPagec = nothing

       Set FSOc = nothing



Case "tmplD"

      ' Write the HTML for your Template D page here using Response.Write

and the FSO to create your text file

       Dim FSOd, myPaged

       Set FSOd = CreateObject("Scripting.FileSystemObject")

       Set myPaged = FSO.CreateTextFile("c:\inetpub\wwwroot\" &

Request.Form("FILENAME") & ".html",True,False)

       myPaged.Write("<html><head><title>This is my title from Template

D</title><body><h1>Hello, world!...more info to follow</h1></body></html>")



       Response.Write("You have successfully created a page from Template

D!")

       Set myPaged = nothing

       Set FSOd = nothing



End Select



%>



Of course you would predefine each page template by using the

myPage{n}.Write method to get the desired look you want.  You could even get

more advanced and propagate the page with DB information or form-entered

values.  This is a basic construct, though.



Hope it helps!



A friend and fellow coder in Guam,

Jason





----- Original Message -----

From: "john hamman" <johnhamman@h...>

To: "ASPToday Discuss" <asptoday_discuss@p...>

Sent: Friday, November 23, 2001 11:46 PM

Subject: [asptoday_discuss] Template to HTML file





> Ok im interested in building a template system that pulls from a template

> (dynamic : user pics a choice tmplA.tmp,tmplB.tmp,tmplC.tmp) and it will

> create from the template a static page from the template. What are some

> steps for this. so far i cant find anything. All i find is pulling from a

> template to form a dynamic single page. I would like to make many static

> pages. In other words every time someone fills out the form, it will

> create a new static page on the server.

> thanks

> john




$subst('Email.Unsub')

>



Message #3 by "Jason Salas" <jason@k...> on Sat, 24 Nov 2001 11:13:45 +1000
There's also a very good example fore how to use templates at:

http://www.4guysfromrolla.com/webtech/020400-1.shtml





----- Original Message -----

From: "john hamman" <johnhamman@h...>

To: "ASPToday Discuss" <asptoday_discuss@p...>

Sent: Friday, November 23, 2001 11:46 PM

Subject: [asptoday_discuss] Template to HTML file





> Ok im interested in building a template system that pulls from a template

> (dynamic : user pics a choice tmplA.tmp,tmplB.tmp,tmplC.tmp) and it will

> create from the template a static page from the template. What are some

> steps for this. so far i cant find anything. All i find is pulling from a

> template to form a dynamic single page. I would like to make many static

> pages. In other words every time someone fills out the form, it will

> create a new static page on the server.

> thanks

> john




$subst('Email.Unsub')

>




  Return to Index