ad_dimensional

one of the documented procedures in this installation of the ACS
Usage:
ad_dimensional   option_list   { url "" }   { options_set "" }   { optionstype "url" }
What it does:
Generate an option bar as in the ticket system;

option_list structure is

    { 
        {variable "Title" defaultvalue
            {
                {value "Text" {key clause}}
                ...
            }
        }
        ...
    }

    an example:

    set dimensional_list {
        {visited "Last Visit" 1w {
            {never "Never" {where "last_visit is null"}}
            {1m "Last Month" {where "last_visit + 30 > sysdate"}}
            {1w "Last Week" {where "last_visit + 7 > sysdate"}}
            {1d "Today" {where "last_visit > trunc(sysdate)"}}
        }}
        ..(more of the same)..
    }
    
Defined in: /web/philip/packages/acs-core/table-display-procs.tcl

Source code:


    set html {}

    if {[empty_string_p $option_list]} {
        return
    }

    if {[empty_string_p $options_set]} {
        set options_set [ns_getform]
    }
    
    if {[empty_string_p $url]} {
        set url [ns_conn url]
    }

    append html "<table border=0 cellspacing=0 cellpadding=3 width=100%>\n<tr>\n"

    foreach option $option_list { 
        append html " <th bgcolor=\"#ECECEC\">[lindex $option 1]</th>\n"
    }
    append html "</tr>\n"

    append html "<tr>\n"

    foreach option $option_list { 
        append html " <td align=center>\["

        # find out what the current option value is.
        # check if a default is set otherwise the first value is used
        set option_key [lindex $option 0]
        set option_val {}
        if { ! [empty_string_p $options_set]} {
            set option_val [ns_set get $options_set $option_key]
        }
        if { [empty_string_p $option_val] } {
            set option_val [lindex $option 2]
        }
        
        set first_p 1
        foreach option_value [lindex $option 3] { 
            set thisoption [lindex $option_value 0]
            if { $first_p } {
                set first_p 0
            } else {
                append html " | "
            } 
            
            if {[string compare $option_val $thisoption] == 0} {
                append html "<strong>[lindex $option_value 1]</strong>"
            } else {
                append html "<a href=\"$url?[export_ns_set_vars "url" $option_key $options_set]&[ns_urlencode $option_key]=[ns_urlencode $thisoption]\">[lindex $option_value 1]</a>"
            }
        }
        append html "\]</td>\n"
    }
    append html "</tr>\n</table>\n"


philg@mit.edu