Forum OpenACS Q&A: Help with List builder

Collapse
Posted by Nick Carroll on
Hi,

In the code below, the page expects "owner_id" and "url". The resulting page displays a list with two columns: title, and entry_date. I want both columns to be sortable, so that clicking on the column header will sort the rows in the reverse order. The problem I am having is that since the page expects "owner_id" and "url", I get an error, since the sortable headers do not export these variables. How do I export these variables so that they are passed on to the sorted page?

Thanks,
Nick.

#######################################################

ad_page_contract {

    Display all blog entries for a specific owner_id.

} {
    owner_id
    url
    {orderby "entry_date,desc"}
}

set user_id [auth::require_login]

set elements {
    title {
        label {Title}
        display_template {<a href="blog/one-entry?entry_id=@entries.entry_id@">\
@entries.title@</a>}
    }

    entry_date {
        label {Entry Date}
    }
}

# Maybe add category to listing too.                                            

template::list::create \
    -name entries \
    -multirow entries \
    -elements $elements \
    -html {width "100%"} \
    -orderby {
        title {orderby {lower(be.title)}}
        entry_date {orderby entry_date}
    }

db_multirow entries entries {}

ad_return_template
Collapse
3: Re: Help with List builder (response to 1)
Posted by Nick Carroll on
No worries, worked it out myself. Just needed to add the -filters clause, and add the two variables to it, like so:

-filters {
url {}
owner_id {}
}

Collapse
2: Re: Help with List builder (response to 1)
Posted by Peter Alberer on
i think the list builder does not support that. you can add a parameter "pass_to_urls" to proc "ad_proc -public template::list::create". add the parameter "pass_to_urls" and the following code

if { $pass_to_urls != "" } { set list_properties(filters_export) $pass_to_urls }

right after the part

# These are defauls for internally maintained properties
array set list_properties { ... }

then you can pass properties to all of the urls via

list::create \
-name "xxx" \
-pass_to_urls {var1 var2 var3}

hope that helps!

Collapse
4: Re: Help with List builder (response to 1)
Posted by Nick Carroll on
Hi Peter,

That property that you suggested isn't documented. The closest thing to it is -pass_properties, but that just makes variables available in the ADP file.

I found the filter method is working the way I want it to work. But I will test to see if that -pass_to_urls also works.

Thanks for your help.

Cheers,
Nick.