Difference between revisions of "Ns adp registeradp"

From AOLserver Wiki
Jump to navigation Jump to search
(Copied from old API documentation)
 
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
'''NAME'''
 
'''NAME'''
  
: ns_adp_registertag -  Register an XML-like tag that executes an ADP script.
+
: ns_adp_registeradp -  Register an XML-like tag that executes an ADP script.
  
  
 
'''SYNOPSIS'''
 
'''SYNOPSIS'''
  
 +
: '''ns_adp_registeradp''' tag ''?endtag?'' adpstring
 
: '''ns_adp_registertag''' tag ''?endtag?'' adpstring
 
: '''ns_adp_registertag''' tag ''?endtag?'' adpstring
  
 
'''DESCRIPTION'''
 
'''DESCRIPTION'''
  
: '''ns_adp_registertag''' registers an ADP script to be called when the specified beginning and ending tags are used in an ADP. The tag is the beginning tag to look for, and the ''endtag'' is the ending tag to look for. The adpstring is an ADP that will be called when AOLserver encounters the specified tags when processing an ADP.
+
: '''ns_adp_registeradp''' registers an ADP script to be called when the specified beginning and ending tags are used in an ADP. The tag is the beginning tag to look for, and the ''endtag'' is the ending tag to look for. The adpstring is an ADP that will be called when AOLserver encounters the specified tags when processing an ADP.
  
: Try not to confuse '''ns_adp_registertag''' with [[ns_register_adptag]]. This one registers an ADP script that is run by the tag. The other one registers a Tcl proc that is run by the tag.
+
: Try not to confuse '''ns_adp_registeradp''' with [[ns_adp_registerscript]]. This one registers an ADP script that is run by the tag. The other one registers a Tcl script/proc that is run by the tag.
  
: Note: This function cannot be called after the server has started. It must be called in a Tcl script in a virtual server's Tcl directory so that it can be initialized at server startup time.
+
: There are two ways to use '''ns_adp_registeradp''', with and without the ''endtag'' parameter:
 
 
: There are two ways to use '''ns_adp_registertag''', with and without the ''endtag'' parameter:
 
  
 
* If the ''endtag'' parameter is specified, the string of characters between the beginning tag (tag) and the ending tag (''endtag'') is passed to the adpstring. The return value of the ADP will be sent    to the browser in place of the string of text that was specified between the beginning and ending tags. The string is not parsed, which means that you cannot include ADP tags in the string unless you execute [[ns_adp_parse]] on the string inside the ADP that processes the registered ADP tag.
 
* If the ''endtag'' parameter is specified, the string of characters between the beginning tag (tag) and the ending tag (''endtag'') is passed to the adpstring. The return value of the ADP will be sent    to the browser in place of the string of text that was specified between the beginning and ending tags. The string is not parsed, which means that you cannot include ADP tags in the string unless you execute [[ns_adp_parse]] on the string inside the ADP that processes the registered ADP tag.
Line 30: Line 29:
 
'''EXAMPLES'''
 
'''EXAMPLES'''
  
     ns_adp_registertag printdate {
+
     ns_adp_registeradp printdate {
 
         The current date is: <% ns_adp_puts [ns_httptime [ns_time]] %>
 
         The current date is: <% ns_adp_puts [ns_httptime [ns_time]] %>
 
     }
 
     }
Line 38: Line 37:
 
'''SEE ALSO'''
 
'''SEE ALSO'''
  
: [[ns_register_adptag]], [[ns_adp_parse]]
+
: [[ns_adp_registerscript]], [[ns_adp_parse]]

Latest revision as of 07:42, 14 October 2009

Man page: http://aolserver.com/docs/devel/tcl/api/adp.html#ns_adp_registertag


NAME

ns_adp_registeradp - Register an XML-like tag that executes an ADP script.


SYNOPSIS

ns_adp_registeradp tag ?endtag? adpstring
ns_adp_registertag tag ?endtag? adpstring

DESCRIPTION

ns_adp_registeradp registers an ADP script to be called when the specified beginning and ending tags are used in an ADP. The tag is the beginning tag to look for, and the endtag is the ending tag to look for. The adpstring is an ADP that will be called when AOLserver encounters the specified tags when processing an ADP.
Try not to confuse ns_adp_registeradp with ns_adp_registerscript. This one registers an ADP script that is run by the tag. The other one registers a Tcl script/proc that is run by the tag.
There are two ways to use ns_adp_registeradp, with and without the endtag parameter:
  • If the endtag parameter is specified, the string of characters between the beginning tag (tag) and the ending tag (endtag) is passed to the adpstring. The return value of the ADP will be sent to the browser in place of the string of text that was specified between the beginning and ending tags. The string is not parsed, which means that you cannot include ADP tags in the string unless you execute ns_adp_parse on the string inside the ADP that processes the registered ADP tag.
  • If endtag is not specified, then no closing tag is required. The ADP will be called every time the specified tag is encountered.
Note: This function is best used in a .tcl file rather than an .adp file, because the parser will be confused by the <% ... %> syntax even though they are in braces.

EXAMPLES

   ns_adp_registeradp printdate {
        The current date is: <% ns_adp_puts [ns_httptime [ns_time]] %>
   }
In your HTML, you simply include a tag called "<PRINTDATE>". This can be extended to provide XML-like template pages for content.

SEE ALSO

ns_adp_registerscript, ns_adp_parse