Forum OpenACS Development: parameters through link

Collapse
Posted by Iuri Sampaio on
Hi there,

I am trying to pass one variable through a link from one application to another. From project-manager/index to acs-subsite/index

The same process works fine when i do from bug-tracker to calendar.

But acs-subsite seems to erase the var.

How do i pass it then?

Collapse
Posted by Dave Bauer on
Hi,

I am not sure what you mean by erasing.

Can you be more specific, what is the URL and parameters that you are passing?

I don't think acs-subsite/index takes and parameters in a default install, do you have custom code in there?

You should check the api-doc for

1) ad_page_contract for processing url vars in the destination page
2) export_vars for generating the url with vars

Collapse
Posted by Iuri Sampaio on
Yes, i am aware of those contraints.
I added the parameter in the ad_page_contact header of subsite index page.

ad_page_contract {

@author mailto:rhs@mit.edu
@author mailto:mbryzek@mit.edu

@creation-date 2000-09-18
@cvs-id $Id: index.tcl,v 1.21 2007/01/10 21:22:06 gustafn Exp $
} {
{project_item_id "" }

...
} -properties { ...

I created an ad_proc that return a url to a specific subsite by giving the subsite id. Based on what we have already on site_node APIs but sligthly diferent. See the string function to take out the /

if { [nsv_exists site_node_url_by_object_id $subsite_id] } {
set url [string trimright [nsv_get site_node_url_by_object_id $subsite_id] /]

set url "$url?project_item_id=$project_item_id"
return $url
}

That assigns to $subsite_url the link:
/project-manager/fred-dispatch-development?project_item_id=2644

in the db_multirow i have the piece of code:

set subsite_id [pm::project::get_subsite_id -project_id $project_id]
set subsite_url [lindex [pm::project::get_subsite_url -subsite_id $subsite_id -project_item_id $project_item_id] 0]
set subsite_name [acs_object_name $subsite_id]

and the listtemplate element is:

subsite {
label "[_ acs-subsite.subsite]"
display_template " a href=\"@projects.subsite_url;noquote@\" @projects.subsite_name;noquote@ /a"
}
*attention to the html tags. I had to take out the braquets to paste in the forum

So, I can see in the browser, at the status bar in botom that link contains the parameter project_item_id
but when i click and go to the acs-subsite index page the var just looses the paramter somehow.
and the url does not show the parameter

I put some ns_log to verify what value is assigned to project_item_id and i confirmed project_id is empty ""

and there is no reason for it that i can see in the code.

Collapse
Posted by Dave Bauer on
First!

Get the subsite_url with the site node procedure! Don't read the nsv directly.

Second build URLs with export_vars then you don't have to play around, removing the trailing slash etc.

Third, I believe you are referring to the bulk actions links at the bottom of the page. If you are, that are not appropriate for a single link. They are for taking actions on multiple items. The bulk actions take their parameters from the key specififed in the list, plus any filters you may have applied.

Collapse
Posted by Iuri Sampaio on
Thanks Dave!
it works.

1. set subsite_url [lindex [site_node::get_url_from_object_id -object_id $subsite_id] 0]

2. set subsite_url [export_vars -base "$subsite_url" {project_item_id}]

3. It is a few strange how the link looks like.
/project-manager/fred-dispatch-development/?project_item_id=2644

i didn't know it was possible having slashes before the '?'