Forum OpenACS Q&A: newbie templating question...

Collapse
Posted by David Kuczek on
I am using .adp pages for the first time and I ran in a problem that I already solved on normal .tcl pages...

Whenever there is a variable called print_p=t in the url the page_content is being displayed with ad_header_print instead of ad_header...

To achieve this I put the following code into ad_header:
ad_page_variables {{print_p "f"}}
  if {$print_p == "t"} {
    set header_html [ad_header_print $page_content]
    return $header_html
  }
}
I guess that I have to enable my master.adp to change src=/master of the slave file to src=/master-print... but how???
Collapse
Posted by Lee Denison on

The way I would enable similar behaviour with the templating system would be to have an ad_page_contract in your master.tcl file:

ad_page_contract {
} {
  {print_p:notnull,optional f}
}

then at the end of the master.tcl you can ad_return_template with either the printable version or the standard version.

if {[string equal $print_p "t"]} {
  ad_return_template "master-print"
} else {
  ad_return_template "master"
}