Forum OpenACS Development: is there a change in the template::list::create behavior?

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.

You can get the base_url usually by using [ad_url], if you have set up your parameters correctly (which hopefully you did).
Hi Malte!

Thanks a lot! Your suggestion is working!

Jorge.

Well, the doubt now is why "link_html {title "File"}" isn't working (or which is the proper way to use it?).

Any clue?.

Thanks a lot!

Jorge.

1) You should not NEED the base url. Make you links either relative to the current URL or relative to the site root. The browser will behave correctly.

2) The reason you get an error for the url column to be missing is that the url column is missing! That is, be default, list builder will check the multirow for a column that matches the name of the element. Your element is named "url" but you don't have a url column in the multirow. If you use display_col or display_template you override that behavior.

Hi Dave,

Thanks a lot, very clear now!!

Jorge.