Your Development & Design Resource

CGI Variables in a CSS Document

I responded to a posting in LDD regarding CGI Variables in a CSS document.
This article describes how I was able to make a "real" CSS from a Form element containing CGI Variable fields.

When setting a form to "Treat contents like HTML", you cannot include domino fields in the form. Doing so will result in the following error:

Error 500

HTTP Web Server: Application Exception - Documents treated as HTML cannot be edited

If I wanted to put, say Remote_Addr (a CGI variable which, when computed to itself, will provide a user's IP address) into a such a form, I would need to either create the field with HTML ("ok" way of getting around it I suppose - but not what I had in mind) which may still not work or find a way to *fool* Domino server into thinking that it wasn't really serving up a form.

... then I thought of it!

First thing's first, I need to give credit to the site who sorta "inspired" this solution. If I could do this for a home page (like I've done here), why can't I do this for a form that's going to act like a CSS document?!?

So I created a completely blank navigator called "name.css". Then I created a form called "$$NavigatorTemplate for name.css", which I set to "Treat contents as HTML" and included a computed for display hidden field called "Remote_Addr" (computed to itself).
Next, I basically started building the CSS:

color: BLACK;
text-decoration: NONE;
color: #8B0000;
text-decoration : underline;


... and now for that computed text...

workList := "";
@IsMember( Remote_Addr ; worklist );
"display: none;";

... And there you have it!.

Now, I used the CSS sheet named name.css like I would normally use a CSS sheet in Domino: Add a field called $$HTMLHead or add to the HTML Head Content section the following code -
version := "main";

db := @ReplaceSubstring( @Subset( @DbName; -1); "\\"; "/");
"<link rel=\"stylesheet\" type=\"text/css\" href=\"/"+ db +"/"+ version +".css\">"

Now this opened the name.css (which is a blank navigator) using the $$NavigatorTemplate for name.css (which actually contains the CSS and the CGI variable) as a mask - returning:
A:LINK, A:ACTIVE, A:VISITED { color: BLACK; text-decoration: NONE; } A:HOVER { color: #8B0000; text-decoration : underline; } TR { color:BLUE; font-family: "MS-Sans Serif"; font-size: 8pt; } .hWork{display: none;}
(hey, I tested this on my local machine...)

With this, I can now "hide" sections of my application based on reffering URLs, user IP addresses, and all other CGI Variable triggers! By using a blank navigator and a $$NavigatorTemplate, I was able to *hack* a fix as well as open up a world of possibilities!!!

About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.

More from is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.