PHL Consult supports OpenNTF and open source

My company, PHL Consult, became member of OpenNTF in August and thereby supports OpenNTF and the use of open source within the Lotus Domino/XPages community. This means that I support the idea of open source in general (and support OpenNTF as an organization) – and that I both contribute code to and reuse code from OpenNTF. I have so far contributed 2 open source XPages custom controls to OpenNTF:

At the time of writing this blog post OpenNTF has 23 company members. Members according to OpenNTF are “companies with the common interest to provide open source for IBM Lotus Notes and Domino and to encourage broad industry use of these applications. To achieve these goals members are willing to devote resources or participate in other ways”.

XPages: only show content for authorized users

Today I was asked: how do you make sure that anonymous users do not see content that only logged on (and thereby authorized) users must see?

I often use a simple solution of having a xp:panel for anonymous users and another xp:panel for authorized users (both on the same XPage). Only one of the two panels are rendered based on whether the user is logged or not. So the two xp:panels would look like this:

Panel 1: for anonymous users

<xp:panel>
<xp:this.rendered><![CDATA[#{javascript:@UserName() == "Anonymous"}]]></xp:this.rendered>
You must log on to see contents.
</xp:panel>

Panel 2: for authorized users

<xp:panel>
<xp:this.rendered><![CDATA[#{javascript:(@UserName() != "Anonymous"}]]></xp:this.rendered>
This is the secret content.
</xp:panel>

You can combine this with the XPages Dojo Login Custom Control available on OpenNTF so that the user can stay on the page when logging on instead of going to a seperate login page.

XPages Web Analytics custom control on OpenNTF

What a great weekend for open source contributions from me! 🙂 Yesterday I created the XPages SEO custom control – and today I have created a new XPages custom control for the OpenNTF development contest called XPages Web Analytics custom control: the custom control makes it easy to add web analytics to your XPages web site.

In the first release the custom control supports Google Analytics and Woopra Web Analytics.

In order to use the custom control you download it from OpenNTF, unzip the downloaded file and open the included Notes database. In the database you will find a custom control called “WebAnalytics” that you can include in your own XPages application. Once included you just drag the custom control to your XPage and add the custom properties for the specific web analytics providers that you would like to use.

XPages SEO custom control on OpenNTF

I have contributed to the OpenNTF development contest by creating an open source XPages Custom Control for Search Engine Optimization (SEO). The custom control makes it easy to add the following search engine friendly tags to your XPages web site:

  • page title
  • meta description
  • meta robots
  • meta keywords

With these SEO tags bundled in a custom control it also increases your chances of remembering to add these tags to your XPages web pages 🙂

Installation is easy:
Just download the SEO custom control, unzip the downloaded file and open the included Notes database. In the database you will find a custom control called “SEO” that you can include in your own XPages application. Once included you just drag the custom control to your XPage and add the custom properties for the specific XPage (either as static or computed values).

I have somehow contributed to OpenNTF

I woke up this morning to a comment by David Jeyachandran to my blog post on Sorting a NotesDocumentCollection by multiple field values. David wanted to let me know that he is using the sort function in the Notes Reconn project at OpenNTF.

That is great news – and I am happy to know that I have contributed to a project on OpenNTF (although just a very small part).

Sorting a NotesDocumentCollection by multiple field values (Show’n Tell Thursday)

I have been using Joe Littons sortCollection function with success to sort a NotesDocumentCollection by the value in a specific field name. However the function can only sort by one field value and I recently had the requirement to be able to sort by multiple field values.

Max Flodén has created a function that does exactly that: sorts a NotesDocumentCollection by one or more field values. But the code from Max uses Evaluate and @Sort to do the actual sorting – and therefore has problems with quotes in the values and apparently also a problem with large collections (see comments to his post).

So I have combined the best from the two sort functions – the sortValues function from Joe Litton that uses Shell sort and the option to sort by multiple field values from Max Flodén – to get a function that sorts a NotesDocumentCollection by one or more field values.

Update: I have updated the sort function to use a fast and easy way of creating an empty NotesDocumentCollection introduced by Peter von Stöckel.

Update November 21: During testing I found an unnecessary loop in the sortCollection function. I have therefore updated the sort function.

Update December 9, 2011: The function is now available on the new OpenNTF XSnippets site.