Index: openacs-4/packages/acs-templating/www/doc/migration.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/migration.html,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-templating/www/doc/migration.html 27 Oct 2014 16:40:14 -0000 1.3 +++ openacs-4/packages/acs-templating/www/doc/migration.html 7 Aug 2017 23:48:02 -0000 1.4 @@ -12,10 +12,10 @@

In a Nutshell

- When templatizing a legacy tcl page, your task is to - separate code and graphical presentation. The latter goes + When templatizing a legacy Tcl page, your task is to + 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. + 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 @@ -36,7 +36,7 @@

At the end of the Tcl script, you should call ad_return_template. The template runs after the - tcl script, and can use these data sources. + Tcl script, and can use these data sources.

Make sure that the fancy adp parser is enabled in your AOL ini @@ -54,19 +54,19 @@ wait till the headers are written or the page is completed; they may act differently than you expect.

  • - If you can, put code in the tcl file, not between <% + If you can, put code in the Tcl file, not between <% %> in the adp page.
  • - Put HTML in the adp page, not int the tcl program. Put + Put HTML in the adp page, not int the Tcl program. Put reusable HTML fragments in a separate adp file (think of it as a widget) that will be <include>d from - several pages. Prefer this to writing a tcl proc that returns + several pages. Prefer this to writing a Tcl proc that returns HTML.
  • Remember to remove backslashes where you had to escape special characters, as in
    Nuts  \$2.70 \[<a href=\"shoppe[<a href="\"shoppe\">buy</a>\]
     	  
    @@ -90,17 +90,17 @@ <form>. I reformatted it a bit to make three panes fit next to each other and to line up corresponding code.

    - +
    - - + + - - -
    old tcl codenewold Tcl codenew
    packages/news/www/item-view.tcl packages/news/www/item-view.adp
    +
     # /packages/news/admin/index.tcl
     ad_page_contract {
    @@ -148,7 +148,7 @@
     return
     	  
    +
     
     ad_page_contract {
    @@ -195,7 +195,7 @@
     ad_return_template
     	  
    +
     
     
    @@ -249,17 +249,17 @@
         following example shows the part of the index page of
         the News module that uses the mechanism, not a whole page.
     
    -    
    +    
    - - + + - - - - - + + + - - -
    old tcl codenewold Tcl codenew
    packages/news/www/index.tcl packages/news/www/index.adp
    +
     ad_page_contract {
     
    @@ -275,7 +275,7 @@
     }
     	  
    +
     ad_page_contract {
     
    @@ -293,19 +293,19 @@
       context_bar:onevalue
       subsite_id:onevalue
       subsite:multirow
    -  item:multirow
    +  item:multirow
       footer:onevalue
     }
     	  
     
    ..................
    +
     append body "
     <ul>
    @@ -319,8 +319,8 @@
         and (   expiration_date is null
              or expiration_date > sysdate)
     } {
    -    append body "<li><a href=
    -	\"item-view?news_item_id="\
    +    append body "<li><a href="
    +	\"item-view?news_item_id="\
     	"$news_item_id\"
     	>$title</a>\n"
     
    @@ -341,13 +341,13 @@
     </ul>
     "
    +
     
     
     
     
    -db_multirow item news_items_select {
    +db_multirow item news_items_select {
         select news_item_id, title
         from news_items_obj
         where context_id = :subsite_id
    @@ -357,13 +357,13 @@
     }
     	  
    +
     
     <ul>
     
     
    -<multiple name=item>
    +<multiple name=item>
     
     
     
    @@ -372,12 +372,12 @@
     
     
       <li><a href=
    -      "item-view?news_item_id=<%
    -      %>@item.news_item_id@"
    -      >@item.title@</a>
    +      "item-view?news_item_id=<%
    +      %>@item.news_item_id@"
    +      >@item.title@</a>
     </multiple>
     
    -<if @item:rowcount@ eq 0>
    +<if @item:rowcount@ eq 0>
       <li>There are
       currently no news items
       available.
    @@ -420,28 +420,28 @@
         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
    +    output from sql and also the output of Tcl procedures using that
         value.
     
    -    
    +    
    - - + + - - - - - + + + - - -
    old tcl codenewold Tcl codenew
    packages/acs-core-ui/www/pvt/alerts.tcl packages/acs-core-ui/www/pvt/alerts.adp
    +
     ad_page_contract {
         @cvs-id $Id$
     } {
     }	  
     	  
    +
     ad_page_contract {
         @cvs-id $Id$
    @@ -462,11 +462,11 @@
     	
     
    ..................
    +
     
     
    @@ -494,15 +494,15 @@
          # alert has been disabled 
          set status "Disabled"
          set action "
    -     <a href=\"/bboard/alert-reenable\">
    -     Re-enable</a>"
    +     <a href="\"/bboard/alert-reenable\">
    +"     Re-enable</a>"
        } else {
          # alert is enabled
          set status "
          <font color=red>Enabled</font>"
          set action "
    -     <a href=\"/bboard/alert-disable\">
    -     Disable</a>"
    +     <a href="\"/bboard/alert-disable\">
    +"     Disable</a>"
        }
     
        append existing_alert_rows "<tr>
    @@ -546,7 +546,7 @@
     }
     	  
    +
     set discussion_forum_alert_p 0
     
    @@ -596,7 +596,7 @@
     	  
     	  
    +