Ns adp registeradp

From AOLserver Wiki
Jump to: navigation, search

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