Forum OpenACS Development: Annoying multirow behaviour

Collapse
Posted by Mark Aufflick on
It seems that if a multirow is extended in the template::query call eg:

template::query get_categories categories multirow "select category_id as id, category_name as name from ec_categories order by sort_key" -eval {
    set row(url) "category-browse?category_id=$row(id)"
}
then you can't just append a row with something like:

template::multirow append categories "" "All Products" "all_products_url"
because the extended url column never gets set. Instead you need to:

template::multirow append categories "" "All Products"
set rownum [template::multirow size categories]
template::multirow set categories $rownum "url" "foobar"
This is somewhat annoying, and it means that code could break further down your existing tcl file if you change a column from being db-generated to being tcl-generated.
Collapse
Posted by Lars Pind on
Mark,

This is what db_multirow's -extend switch does for you.

The trick is that the additional column needs to go into the special categories:columns list as well.

Why are you using template::query and not db_multirow?

/Lars

Collapse
Posted by Mark Aufflick on
ah - so categories:columns is what i was looking for. I assume that's how positional columns (as opposed to named only columns) are determined.

the template::query example comes from 2002 vintage queries in ecommerce by Bart T - I wasn't quite sure why he used it either, but it's all over the place in ecommerce.

Since db_multirow takes care of all that for me, i'll just convert the calls where necessary.

Thanks Lars - as always, your knowledge is prodigious!