Forum OpenACS Q&A: Re: Using list-builder and order by

Collapse
Posted by Lars Pind on
Glad to see that you guys are using the list builder.

A few minor comments:

1) You can get template::list::orderby_clause to spit out the 'order by' part as well by adding the switch -orderby. I just realized that this switch wasn't documented so I added the documentation.

2) I usually specify the call to orderby_clause directly in the query in the .xql file:

select ...
from  ...
where  ...
[template::list::orderby_clause -name listname -orderby]

3) Your -filters trick to add task_revision_id is unfortunalyte the only way to get the list builder to export variables right now. However, for good measure, you should add an empty list afterwards, like this:

-filters {
    task_revision_id {}
}

The reason is that filters normally have specificaion blocks, just like any other element. It doesn't make any difference in this situation, but if you were to add another filter later, you could run into trouble, because the 'name' and 'specification' blocks could be confused.

-filters {
  task_revision_id
  some_other_filter {
      label "This will not do what you want it to"
  }
}

4) If you add a 'default_value refvision_id' to your orderby section, you won't have to do if exists_and_not_null orderby part:

-orderby {
        revision_id {orderby revision_id}
        percent_complete {orderby percent_complete}
        start_date {orderby start_date}
        end_date {orderby end_date}
        default_value revision_id
    } \

5) And then to answer your question to me in private email: No, there's currently no way to change the name of the query parameter used for orderby currently named 'orderby'. Which means you cannot have multiple sorted lists on the same page. I'll look into fixing this.

/Lars

Collapse
Posted by Lear Zumaeta on
Hi Lars, forgiveness for asking to much,

this is a portion of the script that I want to pass parameters
index_lista.tcl

if {  [string equal $keyword {}] } {

  if {  ! [ string compare $sql1 "no"] } {

        set display "doc_list"
        set band4 "12"
        element set_error func_search error2_search " Por favor introduzca su busqueda"
        return
        } else {
# past of parameter to prueba_list_builder?
template::forward prueba_list_builder?sql1=$sql1
}

#This is the code for the prueba_list_builder

ad_page_contract {
} {
            {page:optional}
}

request create -params {
  sql1 -datatype text -optional
}

if { ! [request is_valid] } { return }

set sql1 $sql1

list::create -name users \
        -multirow users \
        -key num_sec \
        -pass_properties { sql1 } \
        -page_size 10 \
        -page_query { select num_sec from procadm.t_normas where $sql1} \
        -elements {
                  num_sec {
                        display_template {<table width="800" border="0" cellspacing="6" cellpadding="6"><tr><td width="2%" valign="top" align="center"><font face="Arial, Helvetica, sans-serif" color="#FF0000" size="3"><b><img src="puntero.gif" width="17" height="17"></b></font></td><td width="96%" valign="top" align="justify">@sql1@<br>@users.desc_norma@&nbsp;@users.num_norma@&nbsp;de&nbsp;@users.anio_gac@<br>Número de Gaeta:&nbsp;@users.num_gaceta@<br>Autoridad:&nbsp;@users.desc_autoridad@<br>Título:&nbsp;@users.titulo@</td></tr></table> }
            }
        }

  set query  "select a.num_sec num_sec, num_gaceta,to_char(fecha_gaceta,'yyyy') anio_gac, a.norma, desc_norma, num_norma, titulo, cod_autoridad,
desc_autoridad \
from procadm.t_normas a, procadm.t_tipo_norma b,procadm.t_autoridad c where $sql1 and \
a.norma=b.num_sec and
a.cod_autoridad=c.num_sec and
a.num_sec in ([template::list::page_get_ids -name users])"

db_multirow users users_query $query

the view showme the value of variable for the first page but when I past to the second the variable lost the value