Forum OpenACS Development: Re: A Model for the Navigation Bar

Collapse
Posted by Jim Lynch on

In a similar way we made the urls which pointed at the detail page (but in that case, expanded the navigation bar by one link), we can also use export_vars to create each delete url. This time, the value of context_fragment that exists for this page, needs to be preserved as it is. The way we'll accomplish that, is we'll send the value to the delete "page" (which only does the delete, then redirects back (with the context_fragment value) to the preferences page. So, the link will have the current value of context_fragment, and we build the link like this:

set delete_url \
    [export_vars \
        -base delete-thing \
        {thing_id context_fragment}]

Compare this to the export_vars that makes the one-thing url.

The parts of the delete script relevent to this mechanism:

delete-thing.tcl:

ad_page_contract { deletes a thing, then returns to preferences. } -query { thing_id:integer context_fragment } -properties { context_fragment : onevalue }

# here, you would check to see if the user has permission # to delete

# then, tell the database to delete the thing

# we're done, so redirect back to preferences

set return_url \ [export_vars \ -base preferences \ {context_fragment}]

ad_returnredirect $return_url ad_script_abort


A few facts,,, One, ad_page_contract is how we told the script to expect some vars (here, context_fragment and thing_id), and under normal conditions, it would cause delete-thing.adp to be run, which would create a separate page for the delete script. This gets short-circuited by the ad_script_abort call, so the .adp never gets called. We don't even need the delete-thing.adp file.

Next: going from a "deeper" page to the next "shallower" page