logo

Tips Week 2.4 - Tab Highlighting in CSS

One of the tips I had jotted down was a bit of a joke really. Along the lines of "don't eat yellow snow". This was a lesson I learnt the hard way some time ago — If your only access to a server console is via webadmin and you need to restart the web server, make sure you use "tell http restart" and not "tell http q". There's no way to follow this up with "tell http load" when http ain't there!

Anyway, a real tip for you. Something I learnt recently while working with clearleft was a way to highlight the current tab using nothing but CSS. On this site, right now, either the Home or the Blogs tab is highlighted, depending which way you came to the site.

This highlighting uses a CFD field, called "currTab", on every form to store the name of the tab that should be highlighted. In the "navigator" subform each tab has a Computed Value area that refers to this field. In the Articles tab (inside the <li> tag)is a computed area of:

@If(currTab="Articles"; "class=\"on\""; "")

This works but it relies on computed fields and six computed values. You can do away with this computation by using nothing but CSS.

In each form add the name of the tab to highlight as a class name to the Body tag, so you get this:

<body class="blogs">

In the each tab in the navigation subform give each element an ID that follows the naming convention, like so:

<li id="tab-blogs"><a href="blogs?OpenView"...

Then, in your CSS add:

body.blogs #tab-blogs, body.articles #tab-articles{ /* etc */
background-color: #fff;
}

Et voila, no computing and no fields. Makes sense?

Comments

  1. A nice addition to this method is using computed fields in your css file (if you use a Domino page to hold it).

    Simply do a lookup to find out which 'areas' your site has, and use computed text to write out your css selectors. Then you won't have to edit your css if you add a new tab.

  2. As we approach the end of the 'Tips' series... What about a Domino based 'Site of the Day' series all next week based around sites that use domino (in some form or other)?... a bit like the Macromedia Hall of Fame.

    • avatar
    • Tom
    • Thu 16 Mar 2006 02:26 PM

    ehm... maybe "tell http q" cannot be followed with "tell http load", but you surely could use "tell http q" and follow up with "load http" in the server console via webadmin, or am I missing something here?

    Btw great tips!

  3. @ Tom

    I think the working assumption is that WebAdmin runs on the http task, so if the task is stopped, your request back to the server from the webadmin client to "load http" will not be heard.

    Nice tip, Jake. I like Adams suggestion too, makes it a bit more portable.

    • avatar
    • Tom
    • Thu 16 Mar 2006 02:56 PM

    @Jerry

    thanx your totally right, should have read better

  4. @jake:

    have you heard ever about a small

    "DOMINO LITE "subset version of domino 7 ?

    • avatar
    • Jake
    • Thu 16 Mar 2006 03:34 PM

    makerjoe. no.

  5. Also sometimes you need to do the "tell http q"/"load http" shuffle because a "tell http restart" doesn't always do the same thing - an example is changing SSL/HTTPS settings.

  6. How about restart task http

    • avatar
    • Jono
    • Mon 20 Mar 2006 04:57 PM

    Been away 4 a few days hence the late response, but if u knocked out http you could always use @Command( [AdminRemoteConsole] ) - (on a smarticon maybe) to get to the console?

  7. Glad you picked up on the CSS-for-tabs stuff we've been doing. We're all for moving any presentation logic we can into the style sheet - it's where it belongs afterall.

    Sometimes this makes the style sheets quite weighty (still small compared to your average image), but browsers only load them once and I think most would agree it's better to make the browser work a little harder than burdening the server with extra work. Up to a point anyway.

Your Comments

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


About This Page

Written by Jake Howlett on Thu 16 Mar 2006

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

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 »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content