logo

Keeping your head nice and tidy

This is one of those little things that, until you know about it, you never realise you miss. Then, when you find out, end up using it all the time.

In Domino Designer when you want to add things inside the <head> tag you do so in the "HTML Head Content" section or in the $$HTMLHead field if still using 4.6.

The problem with this is that whatever you put in there gets sent to the browser as one long line of text. If you are like me and like to keep everything tidy and nicely laid out (even if it doesn't really matter) then this is a pain.

The beauty of the "HTML Head Content" is that you can use formulas in it. This is what got me wondering what happens when you put @NewLine in there. Well, what do you know, it tells Domino to break it up in to separate lines. This way you can format the header of you domino generated page as you would any other page.

Here is an example HTML Head Content:

"<script type=\"text/javascript\" src=\"/" + DBPath + "/rsrc/JavaScripts/$file/global.js\"></script>" + @NewLine + @NewLine +
"<script>" + @NewLine +
"<!-- " + @NewLine +
" var isDocBeingEdited = " + @If(@IsDocBeingEdited; "true;"; "false;") + @NewLine +
"// -->" + @NewLine +
"</script>" + @NewLine + @NewLine +
"<style>" + @NewLine +
"td { + @NewLine +
" font: normal 12px verdana; + @NewLine +
"}" + @NewLine +
"</style>"


The resulting HTML is then:

<script type="text/javascript" src="/dir/DBName.nsf/rsrc/JavaScripts/$file/global.js"></script>

<script>
<!--
var isDocBeingEdited = false;
// -->
</script>

<style>
td {
font: normal 12px verdana;
}
</style>

Rather than the less desirable effect of using no @NewLines:

<script type="text/javascript" src="/dir/DBName.nsf/rsrc/JavaScripts/$file/global.js"></script><script><!-- var isDocBeingEdited = false;// --></script><style>td { font: normal 12px verdana;}</style>

If you have gotten this far (the end) and are thinking you've wasted your time then I'm sorry. Otherwise I hope you enjoy making use of this little snippet.


Feedback

  1. Better yet...

    I use this often-- and I take it one further. To clean up the code, you can do something like this:

    CR:= @Newline; "// -->" + CR + "</script>" + CR + CR + "<style>" + CR +

    Easier/quicker to type, and then even the Domino code looks neater!

    --dave

  2. Another idea

    You can keep the head even tidier by indenting your code and styles. Use the tab character: @Char(9) wherever you want to keep it easy to read.

    If you want lots of them then you can use: @Repeat( @Char(9); x );

    Or, in LotusScript:[<br clear="all" /><pre class="LotusScript">] Private Function InsertTabs (Byval NoTabs As Integer) As String Dim a As Integer For a = 1 To NoTabs InsertTabs = InsertTabs & Chr(9) Next End Function[</pre>] and then in your code: [<code class="LotusScript">] Print InsertTabs(2) & |this is indented| [</code>] HTH Jake -CodeStore

    1. Re: Another idea

      I just get all my code headers and give them variable names, then put them together in a list and then to display it use. e,g,

      T := @GetProfileField("ProfileSystem"; "DbTitle");

      A := @GetProfileField("ProfileSystem"; "DbAuthor");

      B := "<base href=\"" + Server_Name + "/" + @WebDbName + "/\">";

      MD := @GetProfileField("ProfileSystem"; "MetaDescription");

      @implode(A : B : T : MD; @NewLine);

      That way I can keep all my variables and header fields in a readable order, but still get a semblance of readability when viewing page source in the browser. (I like the idea of @Repeat(Char(9); x) though.. Might start using that.

  3. even BETTER yet...

    <rant> If they (IBM/Iris) would fix formulae so that they didn't strip all the carriage returns (and tabs) then we wouldn't have to mess with this.

    I too use the cr=@Newline trick, but it irks me that I can either have cut-and-paste ease between Dreamweaver and Domino, OR I can have neat HTML for the browser. (When using Javascript, sometimes this matters for more than just readability!) It is (in my opinion) retarded that they don't fix this. (Yes, I know I'm complaining to the wrong people...) </rant>

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Quick Tips"

« Previous Article Next Article »
Creating a dynamic, re-usable message form   Using a form as a database's Homepage

About This Article

Author: Jake Howlett
Category: Quick Tips
Keywords: head; html;

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »