Hi,
I'm using the list-builder in order to show a list of the files in a folder.
I have two versions of the list-builder. Using one version I have the desired behavior and using another version I have an error.
Previous observation: I'm using OpenACS 5.3.0 and both versions uses a multirow ("listfiles") with two fields: "rev_title" and "item_nr".
Running version:
*************
template::list::create \
-name listfiles \
-no_data "No files in the folder." \
-key item_nr \
-page_size 20 \
-page_query_name files_qry_paginator \
-page_flush_p 1 \
-actions {
"Insert a new file" new_file {}
} \
-elements {
rev_title {
label "Title"
}
edit {
label "Edit file"
link_url_col edit_url
display_template {
<img src="/resources/acs-subsite/Edit16.gif" height="16" width="16" alt="Edit" border="0">
}
sub_class narrow
html { align center }
}
url {
label "Download file"
link_url_col display_url
display_template {File}
sub_class narrow
html { align center }
}
}
set page_where_clause [template::list::page_where_clause -name listfiles -and -key i.item_id]
db_multirow -extend {
edit_url display_url
} listfiles files_qry {} {
set edit_url "show?[export_vars { item_nr }]"
set display_url "http://127.0.0.1/file/${item_nr}"
}
*************
Version with an error:
*************
template::list::create \
-name listfiles \
-no_data "No files in the folder." \
-key item_nr \
-page_size 20 \
-page_query_name files_qry_paginator \
-page_flush_p 1 \
-actions {
"Insert a new file" new_file {}
} \
-elements {
rev_title {
label "Title"
}
edit {
label "Edit file"
link_url_col edit_url
display_template {
<img src="/resources/acs-subsite/Edit16.gif" height="16" width="16" alt="Edit" border="0">
}
sub_class narrow
html { align center }
}
url {
label "Download file"
link_url_col display_url
link_html {title "File"}
sub_class narrow
html { align center }
}
}
set page_where_clause [template::list::page_where_clause -name listfiles -and -key i.item_id]
db_multirow -extend {
edit_url display_url
} listfiles files_qry {} {
set edit_url "show?[export_vars { item_nr }]"
set display_url "http://127.0.0.1/file/${item_nr}"
}
*************
The error of the second version is: "can't read "listfiles(url)": no such element in array". That is, the template isn't recognizing the extended field "url".
The difference between the versions is that in the extended field "url" the first version is using "display_template {File}" in order to set the title of the url, and the second version is using "link_html {title "File"}" in order to set the title.
Question 1:
Somebody knows why the second version gives error?
Question 2:
How do you obtain the base url for the site (in order to avoid to set "http://127.0.0.1/file/${item_nr}" harcoded)?
Thanks a lot for the help!
Jorge.