Anonymous
Domino 2.0 Rich Internet Applications with IBM Lotus Notes/Domino
You are here: Today » Navigating to previous and next documents
« Caching document info in a field
Document roll back »

Navigating to previous and next documents

This is a nice addition to my blog navigation: when you are reading a blog entry, you can browse to the previous and next ones. Do remember that in a blog, the entries are sorted on their publish date in reverse order. The trick to get the links is using a NotesViewNavigator:

The LotusScript

Function getDocNav(doc As notesdocument)As String
    On Error Goto catch
    Dim s As New NotesSession
    Dim db As notesdatabase
    Dim view As NotesView
    Dim nav As NotesViewNavigator
    Dim entry As notesviewentry
    Dim entry2 As notesviewentry
    Dim tmp As New StringBuffer(5)
    
    Set db=s.CurrentDatabase
    Set view=db.GetView("blog-recent")
    Set nav=view.CreateViewNav
    Set entry=nav.GetEntry(doc)
    
    If Not entry Is Nothing Then
        Set entry2=nav.GetPrev(entry)
        If Not entry2 Is Nothing Then
            tmp.add |<div class="prev"><a href="/domino/pub/| & entry2.ColumnValues(2) & |">« | & entry2.ColumnValues(3) & "</a></div>"
        End If
        Set entry2=nav.GetNext(entry)
        If Not entry2 Is Nothing Then
            tmp.add |<div class="next"><a href="/domino/pub/| & entry2.ColumnValues(2) & |">| & entry2.ColumnValues(3) & " »</a></div>"
        End If
    End If
    getDocNav=tmp.collapse("")
    Goto finally
catch:
    Error Err , "getDocNav, line " & Erl & ": " & Error$
    Resume finally
finally:
End Function

Star rating

40%

Comments

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