Forum OpenACS Development: Re: nesting and list-builder

Collapse
Posted by Claudio Pasolini on
Janine, perhaps you can use list builder, but it's very easy with db_multirow and the multiple tag, as in this small example:

tcl

ad_page_contract {

    @author Claudio Pasolini
    @creation-date  12/04/2003

    @cvs-id index.tcl
} {
    {root_id "486"}
} -properties {
    scripts:multirow
}

set page_title "Lista scripts"
set context [list "Lista scripts"]

# get tree_sortkey from root node
set root_sortkey [db_string root "select tree_sortkey from acs_objects where object_id = $root_id"]

db_multirow scripts query "
    select ci.item_id,
           repeat(' ', tree_level(sc.tree_sortkey) * 4) as indent,
           sc.title as name
    from   mis_scriptsx sc, cr_items ci
    where  sc.tree_sortkey between :root_sortkey and tree_right(:root_sortkey) and
           sc.revision_id = ci.live_revision
   order by sc.tree_sortkey
"

ad_return_template

adp

<master>
  <property name="title">@page_title;noquote@</property>
  <property name="context">@context;noquote@</property>

<table>

  <tr bgcolor=#6699cc>
    <th>Codice</th>
    <th align=left>Descrizione</th>
  </tr>

  <multiple name=scripts>

    <if @scripts.rownum@ odd>
      <tr bgcolor=#eeeeee>
    </if>
    <if @scripts.rownum@ even>
      <tr bgcolor=#ffffff>
    </if>
      <td>@scripts.indent;noquote@@scripts.item_id;noquote@</th>
      <td>@scripts.name;noquote@</th>
    </tr>

  </multiple>

</table>

Hope this helps.