Forum OpenACS Q&A: How to integrate an existing category with other package?

OACS tutorial document reads like below
=============below==========================================
Once the category trees have been selected users need a way to categorize items. The easiest way to do this is by adding the category widget type of the form builder to note-edit.tcl. To achieve this we'll need to use the -extend switch to the ad_form command. Here's the "meat" of the note-edit.tcl page:

ad_form -name note -form {
    {item_id:key}
    {title:text {label Title}}
}

set package_id [ad_conn package_id]

set category_trees [category_tree::get_mapped_trees $package_id]

foreach tree $category_trees {
    foreach { tree_id name subtree_id } $tree {}
    ad_form -extend -name note -form \
        [list [list category_id_${tree_id}:integer(category),optional \
                  {label $name} \
                  {html {single single}} \
                  {category_tree_id $tree_id} \
                  {category_subtree_id $subtree_id} \
                  {category_object_id {[value_if_exists entry_id]}}]]
}

========end of below=======================================

As like before, it generate a kind of chronicle error..
===========error start=====================================
Request Error
can't read "element(value)": no such element in array
    while executing
"lindex $element(value) 0"
    (procedure "template::widget::category" line 17)
    invoked from within
"template::widget::$element(widget) element $tag_attributes"
    (procedure "template::element::render" line 10)
    invoked from within
"template::element::render note category_trees {  }"
    ("eval" body line 1)
    invoked from within
"eval template::element::$command $form_id $element_id $args"
    (procedure "template::element" line 2)
    invoked from within
"template::element render ${form:id} category_trees {  } "
    invoked from within
"append __adp_output "[template::element render ${form:id} category_trees {  } ]""
    ("uplevel" body line 106)
    invoked from within
"uplevel {
===============end of error================================

Also I beleive there are someone who can help me...

I'm still waiting for answers...
Sample codes from developer's tutorial and from category document doesn't work.
I attached trial code and result in the above post.
I found out that the information in the tutorial is  ambiguous and I could only make it work on a HEAD installation. Well, I could at least make this one work: https://openacs.org/doc/openacs-5-1/ch10s06.html

There are actually two documents about categories in the tutorial: https://openacs.org/doc/openacs-5-1/acs-package-dev.html

Hope this helps.