Index: openacs-4/packages/acs-templating/www/doc/migration.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/migration.adp,v
diff -u -r1.3.2.6 -r1.3.2.7
--- openacs-4/packages/acs-templating/www/doc/migration.adp 21 Aug 2015 10:49:22 -0000 1.3.2.6
+++ openacs-4/packages/acs-templating/www/doc/migration.adp 25 Aug 2015 18:02:10 -0000 1.3.2.7
@@ -2,31 +2,40 @@
As usual, the Tcl page should start with a call to
+ As usual, the Tcl page should start with a call to
At the end of the Tcl script, you should call
+mechanisms for handling multirow data sources; see below. At the end of the Tcl script, you should call
Make sure that the fancy adp parser is enabled in your AOL ini
-file.Templating an Existing Tcl Page
Templating System : Migration
+Templating an Existing Tcl Page
+Templating System
+ : Migration
In a Nutshell
+
When templatizing a legacy tcl page, your task is to
-separate code and graphical presentation. The latter goes
+separate
+ code and graphical presentation. The latter goes
into an ADP file; it contains essentially HTML, augmented by a few
-special tags and the \@variable\@
construct. The
+special tags and the \@variable\@
+ construct. The
code goes into a Tcl script. In other words, a templated page
consists of two files, a Tcl part that puts its results in data
sources, and an ADP page (the template), into which these data
sources will be interpolated to yield a complete HTML page.
-General
General
+ad_page_contract
. In its -properties
block you promise the data sources that your script will provide;
they were earlier called page properties, hence the name
of the option. Then your script performs all the computations and
queries needed to define these data sources. There are special
-mechanisms for handling multirow data sources; see below.ad_return_template
. The template runs after the tcl
-script, and can use these data sources.
+script, and can use these data sources.
Make sure that the fancy adp parser is enabled in your AOL ini +file.
+[ns/server/myserver/adp] DefaultParser=fancy -
A few more hints
A few more hints
+ns_puts
, ns_write
etc., which don't wait
till the headers are written or the page is completed; they may act
@@ -41,14 +50,19 @@
<form>
tag as always. All HTML tags can be used
+<form>
+ tag as always. All HTML tags can be used
in the ADP file (template).
-First I take a page from the news package as an example. For +
First I take a page from the news package as an example. For
simplicity, I pick item-view
, which does not use a
<form>
. I reformatted it a bit to make three
-panes fit next to each other and to line up corresponding code.
old tcl code | new | |
---|---|---|
db_multirow
, and the repeating part of the HTML output
-is produced by the <multiple>
tag. The following
-example shows the part of the index
page of the News
+db_multirow
+, and the repeating part of the HTML output
+is produced by the <multiple>
+ tag. The following
+example shows the part of the index
+ page of the News
module that uses the mechanism, not a whole page.
<if>
construct to handle
@@ -326,13 +346,15 @@
optional if_no_rows
block, just like
db_foreach
. They aren't used in the example,
though.If you have a more complicated db_foreach, where logic is + +
If you have a more complicated db_foreach, where logic is performed inside the body, then it might be helpful to build your own multirow variable. In the excert below, taken from /pvt/alerts.tcl and /pvt/alerts.adp, the foreach logic made it hard to use the db_multirow because it needed a combination of the output from sql and also the output of tcl procedures using that -value.
old tcl code | new | |
---|---|---|