category::list::get_pretty_list (public)
category::list::get_pretty_list \ [ -category_delimiter category_delimiter ] \ [ -category_link category_link ] \ [ -category_link_eval category_link_eval ] \ [ -category_link_html category_link_html ] \ [ -remove_link remove_link ] \ [ -remove_link_eval remove_link_eval ] \ [ -remove_link_text remove_link_text ] \ [ -tree_delimiter tree_delimiter ] [ -tree_colon tree_colon ] \ [ -tree_link tree_link ] [ -tree_link_eval tree_link_eval ] \ [ -tree_link_html tree_link_html ] \ [ -category_varname category_varname ] \ [ -tree_varname tree_varname ] [ -uplevel uplevel ] \ category_id_list [ locale ]
Defined in packages/categories/tcl/category-list-procs.tcl
Accepts a list of category_ids and returns a pretty list of tree-names and category-names with optional links for each tree and category.
- Switches:
- -category_delimiter (optional, defaults to
", "
)- string that separates the categories in the pretty list
- -category_link (optional)
- optional link for every category-name
- -category_link_eval (optional)
- optional command that returns the link for every category-name. normally this would be a export_vars command that could contain __category_id and __tree_id which refer to category_id and tree_id of the category-name the link will wrap.
- -category_link_html (optional)
- optional list of key value pairs for additional html in a link.
- -remove_link (optional)
- -remove_link_eval (optional)
- -remove_link_text (optional)
- -tree_delimiter (optional, defaults to
"; "
)- string that separates the tree-names in the pretty list
- -tree_colon (optional, defaults to
": "
)- string that separates a tree-name from the category-names in that tree.
- -tree_link (optional)
- optional link for every tree-name
- -tree_link_eval (optional)
- optional command that returns the link for every tree-name. normally this would be a export_vars command that could contain __tree_id which refer to tree_id of the tree-name the link will wrap.
- -tree_link_html (optional)
- optional list of key value pairs for additional html in a link.
- -category_varname (optional, defaults to
"__category_id"
)- name of the variable that will hold the category_id for category link generation.
- -tree_varname (optional, defaults to
"__tree_id"
)- name of the variable that will hold the tree_id for category and tree link generation.
- -uplevel (optional, defaults to
"1"
)- upvar level to set __tree_id and __category_id for link generation.
- Parameters:
- category_id_list (required)
- tcl-list of categories to display.
- locale (optional)
- locale of the category-names and tree-names.
- Returns:
- pretty list of tree-names and category-names
- Author:
- Timo Hentschel <timo@timohentschel.de>
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if {$category_link_eval ne ""} { upvar $uplevel $category_varname category_id $tree_varname tree_id } elseif {$tree_link_eval ne ""} { upvar $uplevel $tree_varname tree_id } set sorted_categories [list] foreach category_id $category_id_list { lappend sorted_categories [category::get_data $category_id $locale] } set sorted_categories [lsort -dictionary -index 3 [lsort -dictionary -index 1 $sorted_categories]] set cat_link_html "" foreach {key value} $category_link_html { append cat_link_html " $key=\"$value\"" } set cat_tree_link_html "" foreach {key value} $tree_link_html { append cat_tree_link_html " $key=\"$value\"" } set result "" set old_tree_id 0 foreach category $sorted_categories { lassign $category category_id category_name tree_id tree_name set category_name [ns_quotehtml $category_name] if {$category_link_eval ne ""} { set category_link [uplevel $uplevel concat $category_link_eval] } if {$remove_link_eval ne ""} { set remove_link [uplevel $uplevel concat $remove_link_eval] } if {$category_link ne ""} { set category_name "<a href=\"[ns_quotehtml $category_link]\"$cat_link_html>$category_name</a>" } if {$remove_link ne ""} { append category_name " <a href=\"[ns_quotehtml $remove_link]\" title=\"Remove this category\">$remove_link_text</a>" } if {$tree_id != $old_tree_id} { if {$result ne ""} { append result $tree_delimiter } set tree_name [ns_quotehtml $tree_name] if {$tree_link_eval ne ""} { set tree_link [uplevel $uplevel concat $tree_link_eval] } if {$tree_link ne ""} { set tree_name "<a href=\"[ns_quotehtml $tree_link]\"$cat_tree_link_html>$tree_name</a>" } append result "$tree_name$tree_colon$category_name" } else { append result "$category_delimiter$category_name" } set old_tree_id $tree_id } return $resultXQL Not present: Generic, PostgreSQL, Oracle