template::list::orderby_clause (public)

 template::list::orderby_clause -name name [ -orderby ]

Defined in packages/acs-templating/tcl/list-procs.tcl

Get the order by clause for use in your DB query, or returns the empty string if not sorting in the DB.

Switches:
-name (required)
List name
-orderby (optional, boolean)
If this is specified, this proc will also spit out the "order by" part, so it can be used directly in the query without saying 'order by' yourself.

Testcases:
No testcase defined.
Source code:
    # Get an upvar'd reference to list_properties
    get_reference -name $name

    if { $list_properties(orderby_selected_name) eq "" } {
        return {}
    }

    set result {}
    template::list::orderby::get_reference -list_name $name -orderby_name $list_properties(orderby_selected_name)

    if {![info exists orderby_properties(orderby_$list_properties(orderby_selected_direction))]} {
        ad_page_contract_handle_datasource_error "invalid value for orderby: $list_properties(orderby_selected_direction)"
        ad_script_abort
    }
    set result $orderby_properties(orderby_$list_properties(orderby_selected_direction))

    if { $orderby_p && $result ne "" } {
        set result "order by $result"
    }

    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: