category_tree::import (public)
category_tree::import -name name [ -description description ] \ -categories categories [ -locale locale ] [ -user_id user_id ] \ [ -creation_ip creation_ip ] [ -context_id context_id ]
Defined in packages/categories/tcl/category-trees-procs.tcl
Insert a new category tree with categories. Here is an example of how to use this in tcl:
set tree_id [category_tree::import -name regions -description {regions and states} -categories { 1 europe 2 germany 2 {united kingdom} 2 france 1 asia 2 china 1 {north america} 2 {united states} }]
- Switches:
- Options:
- -name (required)
- -description (optional)
- -categories (required)
- -locale (optional)
- -user_id (optional)
- -creation_ip (optional)
- -context_id (optional)
- -name
- tree name.
- -description
- tree description.
- -categories
- Tcl list of levels and category_names.
- -locale
- locale of the language. [ad_conn locale] used by default.
- -user_id
- user that adds the category tree. [ad_conn user_id] used by default.
- -creation_ip
- ip-address of the user that adds the category tree. [ad_conn peeraddr] used by default.
- -context_id
- context_id of the category tree. [ad_conn package_id] used by default.
- Returns:
- tree_id
- Authors:
- Jeff Davis
- Timo Hentschel <timo@timohentschel.de>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- category_tree_import
Source code: if {$locale eq ""} { set locale [ad_conn locale] } if {$user_id eq ""} { set user_id [ad_conn user_id] } if {$creation_ip eq ""} { set creation_ip [ad_conn peeraddr] } if {$context_id eq ""} { set creation_ip [ad_conn package_id] } db_transaction { set tree_id [category_tree::add -name $name -description $description -locale $locale -user_id $user_id -creation_ip $creation_ip -context_id $context_id] set parent(0) {} set parent(1) {} set parent(2) {} foreach {level category_name} $categories { set parent([expr {$level + 1}]) [category::add -noflush -name $category_name -description $category_name -tree_id $tree_id -parent_id $parent($level) -locale $locale -user_id $user_id -creation_ip $creation_ip] } category_tree::flush_cache $tree_id } return $tree_idXQL Not present: Generic PostgreSQL XQL file: packages/categories/tcl/category-trees-procs-postgresql.xql
Oracle XQL file: packages/categories/tcl/category-trees-procs-oracle.xql