Forum OpenACS Q&A: Code inside display_template in an element of a list template

Hello,

I would like to include a proc inside the display_template of an element which requires specific information for each row of the list template. I know hoy to execute the proc and get information of it but I don't know how can I give that specific information.
The code I'm writing is as follows:

cancel {
  link_url_col my_url_bad
  display_template {
    <img src="/resources/prueba/cross.jpeg" width="16" height="16" border="0">
    [onedraft::mydraft::get \
        -item_id 7472 \
        -array my_array]
    $my_array(name)
  }
  sub_class narrow
}

I also have a db_multirow which returns me an item_id for each row.

How can I change 7472 for the value returned by db_multirow for each row?

Thanks.

The idea of display_template is to provide adp code which will define how the element will ve displayed, so tcl code is not allowed here ( as you may noticed :) ). 

So.. one way to go is to extend the vars defined in your db_multirow, you can achive that by using the -extend switch ( check this out https://openacs.org/api-doc/proc-view?proc=db_multirow ). 

One example could be something like this: 

...
...
    display_template { 
           ...
        @yourmultirow.name@
           ...
    }
...
...

db_multirow -extend {name} yourmultirow yourmultirow_query { *SQL* } {
...
...
one::mydraft::get -item_id $item_id -array my_array
set name $my_array(name)
...
...
}
Hi Carlos,

within display_template you can only use the syntax allowed on an .adp page.

You can solve the problem executing the onedraft::mydraft::get proc within the db_multirow and assigning the result to a variable (remember to extend the multirow with the variable name).

Finally you can rewrite the clause as:
display_template {
&lt;img src="/resources/prueba/cross.jpeg" width="16" height="16" border="0"&gt;@multirowname.variablename@
}