Forum OpenACS Development: Re: Passing custom variables through pages

Collapse
Posted by Antonio Pisano on
Dear Iuri, without looking at your code, something coming to my mind is: did you define such custom variable as a filter in your template::list? Something like:
-filters {
	a_custom_variable {
	    hide_p 1
        }
        ....
}
This will make the variable be exported by the paginator links. You will need to add the variable to the ad_page_contract definition as well, or it will be ignored even when the URL specifies it. Hope this helps
Collapse
Posted by Iuri Sampaio on
Here it is listtemplate source


list::create \
    -name items \
    -multirow items \
    -key item_id \
    -page_flush_p 1 \
    -page_size 250 \
    -page_query_name select_items \
    -actions {
        "#evex-event.Send_request#" request-proposal "#evex-event.Send_a_request_to_partner#"
    } \
    -bulk_action_method post \
    -bulk_action_export_vars { event_id } \
    -bulk_actions {
        "#evex-event.Send_request#" request-proposal "#evex-event.Send_request_to_all_partners#"
    } \
    -elements {
        title {
            label "#evex-event.Title#"
        }
        distance {
            label "#evex-event.Distance#"
        }
        score {
            label "#evex-event.Category_Score#"
        }
        total {
            label "#evex-event.Total_Score#"
        }
        location {
            label "#evex-event.Location#"
        }
    }

db_multirow -extend { location thumbnail_url} items select_items_page "
    SELECT qa1.item_id, qa1.score AS total, qa2.score, cr.title,
    pa.latitude, pa.longitude, pa.delivery_address AS location,
    to_char((( 3959 * acos ( cos ( radians(:latitude) ) * cos( radians( CAST(pa.latitude AS NUMERIC)) ) * cos( radians( CAST(pa.longitude AS NUMERIC) ) - radians(:longitude) )+ sin ( radians(:latitude) )* sin( radians( CAST(pa.latitude AS NUMERIC) ) ) )) * 1.6)::float, 'FM999999990.00') AS distance
    FROM
    cr_items ci, cr_revisions cr,
    ee_qa_item_info qa1, ee_qa_item_category_score qa2,
    postal_addresses pa,
    acs_data_links adl
    WHERE ci.item_id = cr.item_id
    AND ci.live_revision = cr.revision_id
    AND (ci.content_type = 'ee_venue' OR ci.content_type = 'ee_service')
    AND qa1.item_id = ci.item_id
    AND qa1.item_id = qa2.item_id
    AND adl.object_id_one = qa1.item_id
    AND adl.object_id_two = pa.party_id
    AND adl.relation_tag = 'item_group_rel'

    AND (( 3959 * acos ( cos ( radians(:latitude) ) * cos( radians( CAST(pa.latitude AS NUMERIC)) ) * cos( radians( CAST(pa.longitude AS NUMERIC) ) - radians(:longitude) )+ sin ( radians(:latitude) )* sin( radians( CAST(pa.latitude AS NUMERIC) ) ) )) * 1.6) < :max_distance

    AND ci.item_id IN ($item_ids)
    AND qa2.category_id IN ($categories)
    AND [template::list::page_where_clause -name items -key qa1.item_id ]
    [template::list::filter_where_clauses -and -name items]
    GROUP BY qa1.item_id, qa2.score, cr.title, pa.latitude, pa.longitude, pa.delivery_address
    ORDER BY qa2.score DESC, qa1.score DESC

" {

    set thumbnail_url ""
...
}

Collapse
Posted by Iuri Sampaio on
I thought full TCL script would be better, self-explanatory.

https://pastebin.com/wzJvJrnY

Collapse
Posted by Antonio Pisano on
Your code is compatible with my explanation. Please try:
- adding the filters so variables are exported in the paginator's URLs
- add the custom variable to the ad_page_contract

I am pretty confident this will work. Let us know!

Ciao

Collapse
Posted by Iuri Sampaio on
It does work. custom variables passed through.
Pagination seems a bit weird though. It's unbalanced, neither shows the correct total. I'll make sure my SQL is properly written. Then... Perhaps I'll create a new thread soon! (-: