Hi, I recently looked at navigation in openacs, and specifically the navigation bar. This article contains my findings and hopefully some steps you can apply to get a working navigation bar.
A navigation bar is a line which contains a colon-separated list of links followed by a colon then the title (or abbreviated title) of the current page. You should see an example under the OpenACS logo, at the top left of this page.
Beginning to look at the list structures in use for navigation bars, we first see, representing a single element of the navigation bar, a two-element list, one element is the title of the link, the other is the url to go to when that section of the navbar is clicked.
{url title} or [list url title]
The order that certain openacs API calls expect is exemplified by: {URL Title}, and to represent a complete navigation bar, you'd have a list starting with 0 or more of the two-element lists followed by a single element which is the title of the current page.
{ {url title} {url title} ... {url title} title }
or, to build it up programmatically,
[list [list url title] [list url title] ... [list url title] title]
Now, let's look at getting this structure onto the page.
The set of templates in openacs contains code to display a navigation bar. If they notice a variable called "context", this value will be included in the navigation bar. The specific code to set up the context variable, for the case of a templated page, there will be a tcl file with a call to ad_page_contract at the top, and an adp page which contains html. Assuming our page is called foo, there will be foo.tcl and foo.adp files. Here is some minimal code:
foo.tcl:
ad_page_contract {
demonstrating the context variable
} -query {
: (optional, to tell this page what variables to expect)
:
} -properties {
context : onevalue
}
# notice this variable, context, is in the -properties
# section of the ad_page_contract call; this means context
# needs to be available to the foo.adp file.
set context { {url1 title1} {url2 title2} title3 }
foo.adp:
<master>
<if \@context@ not nil>
<property name="context">@context;noquote@</property>
</if>
Content of page foo )this text will appear on the page below the navigation bar)
SO FAR, this is just the standard ways of doing things, and we're not yet seeing what I came up with.
The next message will introduce the first of my concepts, which is having a variable called context_fragment which holds a list that grows and shrinks as the pages flow.