administration mode
Pssst...Ferdy is the creator of JungleDragon, an awesome wildlife community. Visit JungleDragon


Article: Domino Perfectlinks »

FERDY CHRISTANT - JUN 3, 2004 (07:17:02 PM)

As of now, permalinks are activated on the site. I'm really happy with the results, things turned out to be simpler than I thought and the result is quite elegant, if I may say so myself.

Let's start with the results. URLs generated from this blog template now look like these examples:

main entry to the site

link of a specific blog entry

link of one month's blog entries

link of one category of blog entries

link to all articles

link of a specific article

link of a specific page

link of a specific resource (image or other file)$FILE/code_prev.gif

I'll explain the steps I took to implement the above URLs vs the standard ugly Domino generated URLs:

1. Shorten Unique IDs

To shorten the long, ugly unique IDs to refer to Notes documents, I created my own, using a computed when composed ID field with the @Unique formula in it. Next, for each document type I added a hidden sorted column in each reference view. The column simply computes to the new ID field. From then on, I could refer to every document using a short ID.

2. Rename design elements

I usually use strict and consistent naming conventions for all design elements. For instance, I prefix all user views with "vw". This is not too cute if you want pretty URLs. Therefore I renamed my public views so users can understand them. For instance, "vwBlogsByDate" becomes "archive". Luckily I already had structural names for image resources and style sheets, I always name them with the "images/" and "css/" prefix, respectively.

3. Remove file path info from URLs

Not only do Domino file paths look ugly, they also add nothing to the user experience and they put you in trouble when you move your database. One solution to this is to refer to databases using a replica ID, yet they too look ugly in a URL. Furthermore, if you would copy your database to a new location, you would have a new replica ID and all existing links will be broken.

One other way is to create a substitution rule for your internet document in your server configuration. This is what I did, but read on...I managed to work around the cons of that solution.

The web site rule document that substitutes the "/blog" directory to the right file path, looks like this:

web site rule document

This basically solves our file path problem, it will be invisible from now on. I do realize that this creates a dependancy, one between an application and the server configuration. I consider this a bad practice, which should be avoided wherever possible.

To overcome the dependancy, I made permalinks optional in the blog template. Have a look at the new option at the bottom in the blog template setup screen:

new setup screen

Blog admins are now able to decide whether or not to use permanent links. If they do, they need to make one subsitution rule in the server configuration, in order to benefit from permalinks. If for whatever reason they cannot administer the server or do not want permalinks, they can simply select this in the setup screen. If they do, regular file paths will be used again in the URLs. Flexible enough, right?

How is this last part implemented? Simple, by just modifying one formula. Throughout the blog application I use the base href tag to offset all the URLs that follow in that page. The base href value is a computed text value that is placed in a subform, which is embedded at the top of each form. The formula calculates the base href value based on the choice made in the setup document. Here's the formula I currently use to compute the URL offset value:

tmpPL:= @DbLookup("":"NoCache";"":"";"vwSetup";"Setup";7;[PartialMatch]);
@If(@IsError(tmpPL) | tmpPL = "";
"<base href=\"http://" + Server_Name + "/" + DBPath + "/\" />";
"<base href=\"http://" + Server_Name + "/blog/\" />"

4. Migrate content

I had to write an agent to convert some existing documents. They were given a new short unique ID, and every link in the content was migrated to fit the new situation.

5. Deploy

It is recommended to thoroughly test all your links in the new situation before deploying. The timing of the design refresh, migration of content and the activation of the substitution rule need to be coordinated well


Using combinations of the techniques described above, it is very well possible to let your application serve up elegant URLs.

Share |

Comments: 1


JUN 15, 17:26:18

comment » Hi Ferdy,

Nice to have some Dutch Domino Bloggers around. On the @unique idea, maybe you could do something as in this thread. The @unique isn't as unique as you would wish. With some validation, the last post in this thread may results in shorter and unique urls for the document.

I use it in the groupblog Blogs, articles etc. get a short unid, unless I assign a linktitle to it. This is an extra field, which allows me to compose e.g. the page with the same form as all the blogs. «

Was this document useful to you?
rating Awesome
rating Good
rating Average
rating Poor
rating Useless
required field
required field HTML is not allowed. Hyperlinks will automatically be converted.