category::list::elements (public)
category::list::elements [ -categories_column categories_column ] \ [ -tree_ids tree_ids ] [ -locale locale ] [ -one_category_list ] \ -name name [ spec ]
Defined in packages/categories/tcl/category-list-procs.tcl
Adds list-elements to display mapped categories. To be used in list::create.
Scenario:
you prepare a multirow which is then displated via template::list::createUsage:
you change the list query by adding an outer join to category_object_map and selecting the object_id and the category_id. After having built the multirow holding the list of objects you add a call tocategory::list::collapse_multirow -object_column <<columnname-holding-object_id>> -name <<multirowname>>to collapse the multirow so that it holds only one row per object with a tcl-list of mapped categories in the category column.After you got the multirow, use
category::list::prepare_display -name <<multirowname>> -container_object_id $package_id(or an object other than package_id that the trees are mapped to). This proc will generate one extra multirow column per mapped tree that will hold a pretty list of the categories. The pretty list can be changed with various options (delimiter, links etc). If you want to have only one extra multirow column holding a pretty list of the mapped trees and categories, then you should use the -one_category_list option.To automatically generate the appropriate input to be used in the elements section of template::list::create, use
category::list::elements -name <<multirowname>>followed by extra spec to be used per element. Again, to display only one column use the -one_category_list option.
- Switches:
- -categories_column (optional, defaults to
"categories"
)- beginning of the names of the multirow columns holding the category-names.
- -tree_ids (optional)
- trees to be displayed. if not provided all tree columns in the multirow will be displayed.
- -locale (optional)
- locale to display the tree-names in columns.
- -one_category_list (optional, boolean)
- switch to generate only one additional column in the list that holds a pretty list of tree-names and category-names.
- -name (required)
- name of the multirow for the list.
- Parameters:
- spec (optional)
- extra spec used for the list-elements. you can override the display_template with using "categories" as column holding the pretty list of category-names.
- Author:
- Timo Hentschel <timo@timohentschel.de>
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: array set spec_array $spec if {[info exists spec_array(display_template)]} { set display_template $spec_array(display_template) array unset spec_array display_template } else { set display_template " @$name\.$categories_column;noquote@ " } if {[info exists spec_array(label)]} { set label $spec_array(label) array unset spec_array label } else { set label "Categories" } set spec [array get spec_array] if {$one_category_list_p} { # generate listbuilder input to display one column with pretty list # of tree-names and category-names set result "$categories_column\_all { label \"$label\" display_template {[regsub -all "@$name\.$categories_column\(;noquote\)?@" $display_template "@$name\.$categories_column\_all\\1@"]} $spec }" return $result } else { if {$tree_ids eq ""} { # get tree columns in multirow template::multirow upvar $name list_data foreach column ${list_data:columns} { if {[regexp "$categories_column\_(\[0-9\]+)\$" $column match tree_id]} { lappend tree_ids $tree_id } } foreach tree_id $tree_ids { lappend trees [list [category_tree::get_name $tree_id $locale] $tree_id] } set trees [lsort -dictionary -index 0 $trees] } else { foreach tree_id $tree_ids { lappend trees [list [category_tree::get_name $tree_id $locale] $tree_id] } } # generate listbuilder input to display one column per tree-name showing # pretty list of category-names set result "" foreach tree $trees { lassign $tree tree_name tree_id append result "$categories_column\_$tree_id { label \"$tree_name\" display_template {[regsub -all "@$name\.$categories_column\(;noquote\)?@" $display_template "@$name\.$categories_column\_$tree_id\\1@"]} $spec }\n" } return $result }XQL Not present: Generic, PostgreSQL, Oracle