If you ever used the Web pages template to create your homepage, and if you happen to use the
'create page with HTML' form, you will now how frustrating it is that you can not use many of the
functionalities which you could benefit if you use a normal Notes form to create the page. I wanted
to put a counter and 'last updated' line to my Web page, but I found out that its not easy and
reached quite a good workaround. I will show you how I added a 'last updated' line, and the counter
can be done in a similar fashion. Follow the steps below:
Add a field in the 'Web Page Using HTML' form called lets say 'LMod', make it of type editable with
a default value of '@now'. Now open your Web page that was created earlier with that form and
re-save your doc for the field to take effect.
In the form's query save event, add this line to the end of the code which is already there, 'Call source.fieldsettext("LMod",Str(Now))'
Then create the following shared agent with the property 'run as web user' checked in the agent properties dialog.
In the view 'All Pages' cut the first column (which is made of of 1 and 2 values) and paste it after the column 'Page Title/Name' column. As an optional work, you can add a new column in the 'All Pages' view called 'Last Modified' with the value of 'LMod'.
Create a shared agent with the following attributes:
When? Manually from Actions Menu.
Which? Run Once.
Lotus Script:
Sub Initialize
Dim s As New notessession
Dim db As notesdatabase
Dim v As notesview
Dim doc As notesdocument
Dim doc_v As notesdocument
Dim cgiqs As String
Dim text As String
Set doc = s.documentcontext
Set db = s.currentdatabase
Set v = db.getview("All Pages")
cgiqs = doc.Query_String(0)
If Instr(Lcase(cgiqs) , "&pagename=" ) > 0 Then
text = Mid ( cgiqs , Instr ( cgiqs , "&pagename=" ) + Len (
"&pagename=" ) )
If Instr ( text , "&" ) > 0 Then
text = Left ( text , Instr ( text , "&" ) -1 )
End If
End If
Set doc_v = v.getdocumentbykey(text)
text_d = doc_v.getitemvalue("LMod")
Print "Content-Type:text/plain"
Print "Content-Type:text/html"
Print "<HTML>"
Print "<body BGCOLOR='#FFFFFF' text='#000000'>"
Print"<h5><strong><p align='center'>Last Updated: (" + text_d(0)
+
")</p></strong></h5>"
End Sub
Finally, Add this in your HTML Page:
<!-- For IE-->
<CENTER><IFRAME align="center" width="350" height="40"
SRC="http://www.4c.com.kw/testweb1.nsf/adddate?openagent&pagename=4C"
frameborder=0 noresize scrolling=no></IFRAME></CENTER>
<!-- For Communicator-->
<CENTER><LAYER
SRC="http://www.4c.com.kw/testweb1.nsf/adddate?openagent&pagename=4C"
LEFT="70" WIDTH="640"></LAYER></CENTER>
<BR><BR>
If you want more control you have to use JS and choose based on the user's browser. You can add both tags it will work fine though, but if there are text/tags in between they will not be ignored by the corresponding browser.
This was first published in November 2000