Forum OpenACS Q&A: How can i order the list by alphabetical order?

template::list::create \
    -name notes \
    -multirow notes \
    -actions {"Add a note" note-edit} \
    -elements {
        edit {
            link_url_col edit_url
            display_template {
                <img src="/resources/acs-subsite/Edit16.gif" width="16" height="16">
            }
            sub_class narrow
        }

        title {
            label "Title"

        }
        delete {
            link_url_col delete_url
            display_template {
                <img src="/resources/acs-subsite/Delete16.gif" width="16" height="16">
            }
            sub_class narrow
        }
    }

    db_multirow -extend {
    edit_url
    delete_url
} notes notes_select {
    select ci.item_id,
        n.title
    from    cr_items ci,
            mfp_notesx n
    where  n.revision_id = ci.live_revision
} {
    set edit_url [export_vars -base "note-edit" {item_id}]
    set delete_url [export_vars -base "note-delete" {item_id}]
}
Collapse
Posted by Enrique Catalan on
If I'm not wrong you should do:

1. In the ad_page_contract header add the variable orderby, something like this (orderby:optional)

2. Then add the switch -orderby to your list::create like:
-orderby {
title {n.title asc}
}

3. Finally, in your 'select' query, after 'where n.revision_id = ci.live_revision' add this: [template::list::orderby_clause -name notes -orderby]

At least, something to start with =).

You might find useful to take a look of some examples in .../packages/acs-templating/www/doc/list*