Domino website: page template and navigation
To make sure all pages use the same basic structure and navigation, we have to find a way to create page templates, similar to the Master Pages in .NET. We can do this by using subforms. Out of experience, we need three:
- A "shared" subform with shared fields used on all pages, including some CGI variable fields. This subform never renders any HTML.
- A "head" subform that renders the HTML part of a page up to where the real content begins.
- A "foot" subform that renders the HTML after the content.
To avoid naming conflicts, in my company it is common practice to start each design element name with the first letter in lowercase of the element type. So: vAll for a view alias, nLaunch for a navigator, etc. Numbers are used to sort the elements. So my subforms will be named: s00-Shared, s10-Head and s19-Foot. I include them in the forms as computed subforms. I also include their names as hidden text to be able to identify them at a glance:

Shared fields
For the moment, I have only one: DbPath, computed for display. It comes very handy to have this in one place. To make friendly URLs, tomorrow I will ask our administrator to make a shortcut 'hobby' for this path so that I can have friendly URLs like http://www.tangosite.com/hobby/ instead of the http://www.tangosite.com/pershost/mme/tangosite/michel03.nsf/ I have now. When the shortcut is in place, I will only have to change the field DbPath. And now the fun part: the navigation.
Navigation form fields
Every page can also be included in the top navigation. Therefor, I must add some navigation-specific fields to my page form:
- The key of the navigation set the page belongs to.
- A sort order value to control the order in which the elements are displayed.
- The short title to use in the navigation.
- The key to identify this item.
- An option to store an alternative URL in case we want to use the page as navigation element only, pointing to a form or another element.
All pages also have fields for their title, short description and content. I avoid using Notes RichText fields for content. I add one RichText field to store attachments though.

The views
Every page has a unique key. A view named "pub" with only one sorted column makes every page accessible by this key. Combined with the shortcut, made by an Administrator as a server redirect document, makes all URLs very friendly, e.g.:
/hobby/about-me instead of: /pershost/mme/tangosite/michel03.nsf/0bdea0da4670ecbfc125721b003066a8/.
723a9840b94a8e52c12573040028295b!OpenDocument
For the navigation and other lookups, I use a second view named "index" with three columns:
- First column sorted and categorized:
iKey - Second column sorted:
iSort - Third column:
iValue, the value I want to retrieve.
These three values are from computed fields on the form. In case of the navigation, what I want to retrieve is the key and the HMTL of the navigation entry. I also want to use /$db/ and replace it with the DbPath at the last moment, so iValue is computed as:
ThisKey+"|<li><a href=\"/$db/pub/"+ThisKey+"\">"+ShortTitle+"</a></li>"
I added the pages for the top navigation, giving the following result in the index view:

Computing the top navigation
We now can replace the dummy top navigation with the formula to get all top navigation elements and highlight the element you are on:
a:=@DbLookup(""; ""; "index"; "top"; 3);
b:=ThisKey;
c:=@ReplaceSubstring(a; b+"|<li"; b+"|<li class=\"on\"");
d:=@Word(c; "|"; 2);
@Implode(@ReplaceSubstring(d; "/$db/"; DbPath); @NewLine)
So far, still good
Here is the link to the website in its current state. Next step: embedded views, subnavigation and breadcrumbs.
Comments
21/07/2007 04:30:06, Brian McDowell
This is very helpful. Any thoughts of having the template avaliable for download?
Brian McDowell
To add a comment, log in or register as new user. It's free and safe.