ad_return_template { file_name " " } { cache_p "1" }What it does:
Finds a template to source (looks at what templates are available, what the user prefers, and what the site defaults are), parses it in the caller's environment, and ns_return's the bytes to the user. file_name, if specified, overrides the base file name used to determine which template to use. cache_p, if specified, can disable or enable caching by altering the HTTP header.Defined in: /web/philip/tcl/ad-style.tcl
Source code:
set full_url [ns_conn url] if { [string index $full_url [expr [string length $full_url]-1]] == "/" } { append full_url "index.tcl" } set just_the_dir [file dirname $full_url] if [empty_string_p $file_name] { set file_name [file rootname [file tail $full_url]] } set template_directory "[ad_style_template_root]$just_the_dir" set glob_pattern "${template_directory}/${file_name}.*.adp" set available_templates [glob -nocomplain $glob_pattern] if { [llength $available_templates] == 0 } { ad_return_error "No template available" "We can't find any template for presenting the output of this script. Sorry but you're a victim of our graphics ambition. Please complain to the site owner." } else { # we have at least one template available; we need to score # them against user's criteria, then pick the highest scorer set list_of_lists [ad_style_score_templates $available_templates] set sorted_list [lsort -decreasing -command ad_style_sort_by_score $list_of_lists] set top_scoring_template_filename [lindex [lindex $sorted_list 0] 1] set fully_qualified_template_filename "$top_scoring_template_filename" if { $cache_p } { # build the http header, with a no cache pragma if cache_p is 0 set http_header "HTTP/1.0 200 OK MIME-Version: 1.0 Content-Type: text/html Pragma: No-Cache " eval "uplevel { ns_write \"$http_header\[ns_adp_parse -file \"$fully_qualified_template_filename\"\]\" }" } else { eval "uplevel { ns_return 200 text/html \[ns_adp_parse -file \"$fully_qualified_template_filename\"\] }" } }