Anonymous
Domino 2.0 Rich Internet Applications with IBM Lotus Notes/Domino
You are here: Today » Domino Workspace: Blogs now have an Archive view
« Domino Workspace: The blog calendar
Update: My blog now has a Comments RSS feed »

Domino Workspace: Blogs now have an Archive view

Since all the pages are rendered by LotusScript anyway, I only use the views to look up data. In this case, my "byMonth" view, 1st column categorized by the UniversalID of the room, 2nd column by yyyy-mm, is used for both the Archive overview and the list of posts by month. The blog room document itself acts as viewtemplate for the posts by month when adding ?open&month=yyyy-mm to the URL.

The Archive overview

On every page, there's an Archive overview of the months and the number of posts, exactly like on this blog.

Sub blogArchive(room As notesdocument)
    On Error Goto catch
    Dim view As notesView
    Dim nav As NotesViewNavigator
    Dim entry As NotesViewEntry
    Dim i As Long
    Dim roomKey As String, tmp As String, tmp2 As Variant
    Dim href As String, label As String
    
    Set view=ws.db.GetView("byMonth")
    Set nav=view.CreateViewNavFromCategory(room.UniversalID)
    roomKey=ws.path & "pub/" & room.pageKey(0) & |?open&month=|
    ws.body |<div class="box">|
    ws.body |<b class="bt">Archive</b>|
    ws.body |<ul>|
    Set entry=nav.GetFirst
    While Not entry Is Nothing
        tmp=entry.ColumnValues(1)
        label=monthName2(Cint(Right(tmp,2))) & " " & Left(tmp, 4)
        ws.body |<li><a href="| & roomKey & tmp & |">| & label & |</a> (| & entry.ChildCount & |)</li>|
        Set entry=nav.GetNextCategory(entry)
    Wend    
    ws.body |</ul>|
    ws.body |</div>|
    
    Goto finally
catch:
    Error Err, Error & " in " & Getthreadinfo(1) & ", line " & Erl
    Resume finally
finally:
End Sub

The blog QueryOpen

In the QueryOpen agent of the blog, I look for a ?open&month=yyyy-mm value in the Query_String. If present, the list of blogs for that month is displayed. If not, it renders the most recent:

ws.body |<div id="main">|
qs=ws.doc.Query_String_Decoded(0) & "&"
key=Strleft(Strright(qs, "&month="), "&")
If key>"" Then
    ws.body |<h1>Monthly archive: | & monthName2(Cint(Right(key,2))) & " " & Left(key, 4) & |</h1>|
    byMonth key
Else
    ws.body |<h1>Most recent posts</h1>|        
    blogList "recent", room.UniversalID, "", 5    
End If

The byMonth subroutine

Sub byMonth(Byval key As String)
    On Error Goto catch
    Dim view As notesView
    Dim vc As NotesViewEntryCollection
    Dim entry As NotesViewEntry
    Dim i As Long
    Dim href As String,desc As String
    Dim tmp As Variant
    
    Set view=ws.db.GetView("byMonth")
    tmp=Split(room.universalid & "##" & key, "##")
    Set vc=view.GetAllEntriesByKey(tmp, True)
    ws.body |<ul class="list">|
    ws.debug vc.Count
    For i=1 To vc.count
        Set entry=vc.GetNthEntry(i)
        ws.body |<li>|
        href=ws.path & "pub/" & entry.ColumnValues(3)
        ws.body |<h2><a href=| & href & |>| & entry.ColumnValues(4) & |</a></h2>|
        ws.body entry.ColumnValues(5)
        ws.body |<p><i><a href=| & href & |>Permalink</a> - posted on | & Format(entry.ColumnValues(2)) & | by | & entry.ColumnValues(6) & |</i></p>|
        ws.body |</li>|
    Next
    ws.body |</ul>|
    
    Goto finally
catch:
    Error Err, Error & " in " & Getthreadinfo(1) & ", line " & Erl
    Resume finally
finally:
End Sub

The result

You can see the result in the Blog rooms, e.g. in Random Observations, a test blog by Tim Tripcony. You will also find there that Domino Workspace is now Yoda approved. Thanks, Tim!

Star rating

0%

Comments

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