Forum OpenACS Development: Re: Category Description

Collapse
3: Re: Category Description (response to 1)
Posted by Gustaf Neumann on

You are right, there is no API call provided for obtaining the description of a category. The description is language-specific, and is kept in the table category_translations. One should be able to use a proc in the following style.

I'll commit this later. all the best

-gn

d_proc -public category::get {
    -category_id:required
    {-locale ""}
} {
    
    Get name and description for a category_id in the given or
    connection's locale. If for the combination of category and locale
    no entry in category_translations exists, then empty is returned.

    @option category_id category_id of the category to be queried.
    @option locale locale of the language. [ad_conn locale] used by default.
    @return list of attribute value pairs containing name and description
} {
    if {$locale eq ""} {
        set locale [ad_conn locale]
    }
    
    if {[db_0or1row category_get {
        select name, description
        from category_translations
        where category_id = :category_id
        and locale = :locale
    }]} {
        set result [list name $name description $description]
    } else {
        set result ""
    }
    return $result
}
Collapse
4: Re: Category Description (response to 3)
Posted by Iuri Sampaio on
Thanks Brian, right on!

I figured that out after debugging how category info is inserted into translation.

@Thanks Gustaf,
No rush, that will be my humble contribution to the next release.

Also, I have built a FB authentication, login and registration. But that I'll save for in the future! It still lacks some dots "in the i's" (code optimization and fixes)

I'm pretty sure if we build social media integration packages into OACS, it will attract more people to our community.