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

Collapse
Posted by Jim Lynch on

The moving value: context_fragment

Each page in my scheme (remember, this whole thing is certainly not the only way), receives a value for context_fragment. This value will remain constant for the entire code of the page. It represents the value of context_fragment applicable to the PREVIOUS page.

To get this value, your page must state in the ad_page_contract, that it wants to receive it. I do that like this:

ad_page_contract {
    this is where the docs and purpose for the page are stated
} -query {
    contect_fragment
} -properties {
    :
    :
}

The page will now complain if the variable context_fragment is not passed.

The first thing we will do with it, is copy it into two variables, one called context and the other called new_cntxt_frag, like this:

set context $context_fragment
set new_cntxt_frag $context_fragment

and set the page title:

set title "Title for this Page"

adjust the value of context to have the title as its last list element, making it ready to present to the master template:

lappend context $title

add a new var containing a url to the current page (remember, this url must pass a value for context_fragment):

set self_url \
    [export_vars \
        -base this-page \
        {context_fragment}]

and adjust new_cntxt_frag with a new two-element {url title} list, the value of which will be passed to "newer" pages, represents the context_fragment value for THIS page (not the previous page), and the navigation bar will be seen to have a new link when the page is rendered:

lappend new_cntxt_frag [list $self_url $title]

and, except for the first page, that's it. Each page does basically the same thing, and the navigation bar is just handled.

Next section: the first page