It's Not A Bug, It's A Feature Just another Developer weblog

Doumentation

Advanced ASP Templates Technical Documentation:

  • NewPage.TemplateDB = "[Connection String]"
  • .TemplateDB is an optional property. And only needs a value
    if your template or token's are getting their source from the
    database.

    [Connection String]

    DSN-Less Access DB

    NewPage.TemplateDB = "Data Source=MyDatabase.mdb;Provider=Microsoft.Jet.OLEDB.4.0;"

    SQL

    NewPage.TemplateDB = "PROVIDER=SQLOLEDB;Data
    Source=localhost;UID=myuserid;PWD=mypassword;DATABASE=mydatabase"

  • NewPage.TemplateType = [Template Type]
  • .TemplateType is a required property, and defines what type
    of file/record your template is.

    [Template Type]

    Remote File via "GET"

    NewPage.TemplateType = GetRemoteFile

    This property will use the XML parser to retreive the defined
    template in NewPage.TemplateLocation via the HTTP GET protocol

    Remote File via "POST"

    NewPage.TemplateType = PostRemoteFile

    This property will use the XML parser to retreive the defined
    template in NewPage.TemplateLocation via the HTTP POST protocol

    Local File

    NewPage.TemplateType = LocalFile

    This property will use the FSO (File System Object) to retreive
    the defined template in NewPage.TemplateLocation

    Data Base Record

    NewPage.TemplateType = DBFile

    This property will tell the class that the value in NewPage.TemplateLocation
    is a SQL query and to retreive a record from the database via
    ADODB.Recordset. (NewPage.TemplateLocation must be a SQL query)

  • NewPage.TemplatePost = [Form Data]
  • .TemplatePost is a optional property and is only required
    if NewPage.TemplateType is set to
    PostRemoteFile, and defines what form
    data to post to the template.

    This property will use the value assigned to it and post
    it to the remote file specified in NewPage.TemplateLocation
    = "[File Location]"
    .

    [Form Data]

    Posted Data via Request.Form

    NewPage.TemplateType = Request.Form("MyFormField")

    Posted Data via Set Value

    NewPage.TemplateType = "MyFormField=Test"

  • NewPage.TemplateLocation = "[File Location]"
  • .TemplateLocation is a required property This property will
    use the value assigned to it and pass it to the class file
    for the appropriate action.

    [File Location]

    With .TemplateType set to 'GetRemoteFile' or 'PostRemoteFile'

    NewPage.TemplateLocation = "http://www.mysite.com/layout/template.asp"

    For remote file retrieval all paths must be fully qualified
    URL's

    With .TemplateType set to LocalFile

    NewPage.TemplateLocation = "../layout/Template.txt"

    For local files all paths must be realitive to the class.asp
    file. If the class file is in the root and the template file
    is one directory down then the path would be "mypath/myfile.txt"

    With .TemplateType set to DBRecord

    NewPage.TemplateLocation = "Select Layout from TblHTMl Where ID =1"

    To retreive a record from a data base place a SQL query in the .TemplateLocation. field name in the query is unimportant as the class will return the first column of the first row retrieved regardless of name of column and number of rows returned.


  • NewPage.AddToken "[Token]", [Token Type], [Replace Token With], [Post Data]
  • .AddToken can be assigned unlimited times and is user configureable.

    [Token]

    Can be assigned any value

    NewPage.AddToken "<##MyToken##>",
    ProvidedData, "My text to replace token", ""

    Token is
    a user defined element, what ever value is given will be looked
    for in the main template and replaced with what ever value is
    assigned for that paticular token.

    NOTE: token's are case insensitive, so if the template has a token
    called <##MyToken##> and the add token for the template has
    <##mytoken##> the class will make a match between the two.

    [Token Type]

    ProvidedData

    NewPage.AddToken "<##MyToken##>", ProvidedData,
    "My text to replace token", ""

    The ProvidedData token type will replace the specified token
    with the text provided in [Replace Token With]. The preceding
    example will look for '<##MyToken##> in the template and replace
    it with 'My text to replace token'. When using ProvidedData
    as the [Token Type] the [Replace Token With] value must be enclosed
    in double quotes.

    GetRemote

    NewPage.AddToken "<##MyToken##>", GetRemote,
    "http://www.mysite.com/mypage.asp", ""

    When the [Token Type] is GetRemote the class will retreive the
    file specified via the HTTP GET protocol and find the token
    within the template and replace it with the content of the page
    retrieved.

    PostRemote

    NewPage.AddToken "<##MyToken##>", PostRemote,
    "http://www.mysite.com/mypage.asp", "MyFormField=Test"

    NewPage.AddToken "<##MyToken##>", PostRemote,
    "http://www.mysite.com/mypage.asp", Request.Form("MyFormField")

    When the [Token Type] is PostRemote the class will retreive the
    file specified via the HTTP POST protocol and find the token
    within the template and replace it with the content of the page
    retrieved.

    When using GetRemote the [Post Data] will be posted to the file
    location specified in [Replace Token With]. The form fields
    can be from the Request.Form collection or a set string.

    DBFile

    NewPage.AddToken "<##MyToken##>", DBFile,
    "Select MyTokenData from TblHTML Where ID = 21", ""

    To retreive a record from a data base place a SQL query in the [Replace Token With]. field name in the query is unimportant as the class will return the first column of the first row retrieved regardless of name of column and number of rows returned.


  • NewPage.ShowPage
  • .ShowPage will be assigned the value of the whole template with all tokens replaced. Use NewPage.ShowPage if your page's content is all provided by the tokens. If your page has content in it already and you want to surround it with the template use NewPage.SplitTemplate, NewPage.ShowTop and NewPage.ShowBottom to output the template. You must perform a 'Response.Write NewPage.ShowPage to see the output of this variable.
  • NewPage.SplitTemplate "[Token]"
  • .SplitTemplate specifies a point in the template to perform a split on and assign a the top portion to .ShowTop and the bottom half to .ShowBottom, There must be only one instance of this token.
  • NewPage.ShowTop
  • See NewPage.SplitTemplate.
  • NewPage.ShowBottom
  • See NewPage.SplitTemplate.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)


*

No trackbacks yet.