A one fits all navigator in LotusScript
My Flickr-like page navigation proved still to have some nasty quirks in it. It was a nightmare to debug, but I think it works as intended now. Today I combined all the view navigation and search results in one single $$NavigatorTemplateDefault, powered by a QueryOpen agent. Based on what is passed in the query part of the URL, it switches views, filters out the correct entries or does a full text search.
The LotusScript
Sub Initialize
initPage
On Error Goto catch
Dim view As notesview
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim out As New StringBuffer(100)
Dim nav As New StringBuffer(100)
Dim i As Long, tmp As String, key As String, which As String
Dim xDate As New NotesDateTime("Today")
tmp=getQuery("tag")
If tmp>"" Then
key=tmp
which="tag"
End If
tmp=getQuery("month")
If tmp>"" Then
key=tmp
which="month"
End If
tmp=getQuery("day")
If tmp>"" Then
key=tmp
which="day"
End If
tmp=getQuery("search")
If tmp>"" Then
key=tmp
which="search"
End If
Select Case which
Case "tag"
out.add "<h1>Tag: " & key & "</h1>"
Set view=db.GetView("categories")
Set vc = view.GetAllEntriesByKey(key, True)
out.add viewPage(vc, 10, 2)
Case "month"
Set xDate=setDate(xDate, Cint(Left(key,4)), Cint(Right(key,2)), Nothing)
out.add |<h1>| & monthName(xDate) & " " & Left(key,4) & |</h1>|
Set view=db.GetView("byMonth")
Set vc = view.GetAllEntriesByKey(key, True)
out.add viewPage(vc, 10, 2)
Case "day"
Set xDate=setDate(xDate, Cint(Left(key,4)), Cint(Mid(key,6,2)), Cint(Right(key,2)))
out.add |<h1>| & Cint(Right(key,2)) & " " & monthName(xDate) & " " & Left(key,4) & |</h1>|
Set view=db.GetView("byday")
Set vc = view.GetAllEntriesByKey(key, True)
out.add viewPage(vc, 10, 3)
Case "search"
out.add |<h1>Searchresults for '| & key & |'</h1>|
Set view=db.GetView("vLaunch")
Set vc=view.AllEntries
vc.FTsearch key, 0
out.add viewPage(vc, 10, 1)
Case Else
out.add "<h1>Recent posts</h1>"
Set view=db.GetView("vLaunch")
Set vc = view.AllEntries
out.add viewPage(vc, 5, 1)
End Select
nav.add getTagCloud
nav.add getCalendar(xDate)
nav.add getArchive
Goto finally
catch:
debug.add "Error " & Err & " in line " & Erl & ": " & Error$
Resume finally
finally:
out.add debug.collapse("<br />" & NEWLINE)
doc.replaceitemvalue "MainContent", out.collapse(NEWLINE)
doc.replaceitemvalue "NavContent", nav.collapse(NEWLINE)
End Sub
What next?
All navigation in this blog is now done with the agent described above. Next? I really want to have a go at a voting system, like Jyte and IdeaJam.
Comments
14.10.2007 19:16:24, Jan Schulz
hi you. How do you manage to split the search result into different pages? (I searched for String and got three pages).
This is great stuff! Again :-) any way to get a look at the source of the final flickr Code?
10/14/2007 07:42:27 PM, Charles Robinson
Michel, are you intending to post the full source? getQuery is rather trivial, but I'm intrigued by viewPage. :)
14/10/2007 20:12:19, Michel Van der Meiren
It's in my post of last Friday, guys: "View navigation in Web 2.0 style" :-)
10/15/2007 07:33:25 PM, Charles Robinson
Okay, I hadn't read that one yet. I was saving it for when I was less hectic and could really focus on it. Does it have the updated code you refer to here?
2007-10-16 05:28:31, fang lian
hi,Michel,can you support the demo db to let us download! thanks.
01/08/2009 07:39:47 AM, Navin Thakur
hi , can you plz give me demo db or link
To add a comment, log in or register as new user. It's free and safe.