Anonymous
Domino 2.0 Rich Internet Applications with IBM Lotus Notes/Domino
You are here: Today » Domino website: embedded views and breadcrumbs
« Common JavaScript behaviours for web pages
Domino website: page template and navigation »

Domino website: embedded views and breadcrumbs

Programming Domino to render XHTML sites implements that you treat views in a very specific way. You only use views with the option "Treat view contents as HTML" turned on. Embedding views in pages gives you the most control and you keep your URLs user friendly.

Embedding a view in an XHTML page

To make the whole more flexible, I put the embedded view in a subform which is added to the page only if a specific field is filled in. My index view, used to lookup the top navigation, doubles as embedded view by only making the iValue column visible and turning "Treat view contents as HTML" on. I modified the formula to compute iValue so that when the ParentKey is not "top", it gives a nice view entry instead of the code I needed for the top navigation:

@If(ParentKey="top"; @Return(ThisKey+"|<li><a href=\"/$db/pub/"+ThisKey+"\">"+ShortTitle+"</a></li>"); "");

"<li>"+@NewLine
+"<a href=\""+DbPath+"pub/"+PageKey+"\">"+ShortTitle+"</a>"+@NewLine
+Description+@NewLine
+"</li>"

Note here that I had to hardcode the DbPath in this case, so I have to refresh the documents when the DbPath changes. You can see the result in the About section of the site.

Making a breadcrumb trail with Notes formulas

Since now we have pages that are not in the top navigation, we need a way to navigate them. Since I decided to make the site very shallow, leaving out secondary navigation, a breadcrumb trail is a valid option here. The formula first looks up the top navigation and strips out the <li></li> elements. Then each breadcrumb link is computed individually, returning an empty string when not needed. Finally, the values with the empty ones stripped out are rendered on the page, calculating the DbPath at the last minute:

a:=@DbLookup(""; ""; "index"; "top"; 3);
@If(@IsError(a); @Return(@Text(a)); "");

b:=@If(ParentKey="top"; ThisKey; ParentKey);
c:=@ReplaceSubstring(a; "<li>":"</li>"; "");

v1:=@If(b="home"; ""; @Subset(@Word(c; "|"; 2); 1));
v2:=@If(ParentKey="top"; ""; @middle(@Implode(c; "~"); b+"|"; "~"));
v3:=ShortTitle;

"<p id=\"trail\">"+@Implode(@ReplaceSubstring(@trim(v1:v2:v3); "/$db/"; DbPath); " > ")+"<p>"

The result

Here is the link to the website in its current state. You should definitely read the disclaimer: it's written in true American style. "Dont sue me. I'm not responsible! I didn't do it!"

Star rating

94%

Comments

To add a comment, log in or register as new user. It's free and safe.