[Zope] ``Context sensitive'' table cells

Ramiro Brito Willmersdorf rbw@demec.ufpe.br
Tue, 19 Oct 1999 11:43:03 -0200


Hi,

I'm just starting with Zope, (as a lot of other folk around here,
it seems) and I'm a bit ovewhelmed (same again :)

Anyways, I'm in love, in just a few hours and just using <dtml-var ...>
I built a (skeleton) site that I'd never would have considered even
starting using straight html or something else less powerful.

Again, as a lot of other people seem to be doing these days, I built a menu
structure using tables.  I'd like to have the background color of the cell that
has been selected to change to a different color, to reflect where in the site
you are at the moment.  I came up with the ``code'' below:

  [ ... Table header ... ]
  <tr align=center>
     <td <dtml-if "title == 'Título'">
             bgcolor=<dtml-var bgcurrent>
          <dtml-else>
             bgcolor=<dtml-var bgmenu>
          </dtml-if>>
     <a href="/ABMEC/Consulta/Titulo"> Título </a> </td> </tr>
  <tr align=center>
      <td <dtml-if "title == 'Autor'">
             bgcolor=<dtml-var bgcurrent>
          <dtml-else>
             bgcolor=<dtml-var bgmenu>
          </dtml-if>>
      <a href="/ABMEC/Consulta/Autor"> Autor </a> </td> </tr>

  [ ... Lots of nearly identical rows ... ]
</table>

In the index_html documento in each folder mentioned in the 
anchor tag, I have set the title to the string I'm using the comparison.

This seems to work (as long as I have unique titles! (not really that
bad, as a matter of fact, but not really nice, either)).

Clearly, all those repeated if's are something that would go, with a
more conventional programming language, into a subroutine or macro or
whatever.  I tried to create a DTML method to encapsulate it, but I couldn't
figure out how to pass to it the argument I wanted the title to be compared
to.  I think perhaps I'm still locked into a too conventional mindset
(my being primarily a fortran programmer and all :)

So, I'd like to ask if there is a nicer cleaner way of doing what I wanted to
in the first place (ie, changing the background color of one particular table
cell depending on which folder is being currently viewed), or alternatively
how can I write a DTML method with an argument, to avoid repeating all those
<dmtl-if>'s.

Many thanks,

Ramiro.

PS: Thanks for making everything 8 bit clean :)
    Sorry if this is too simple minded, I did try a lot on my own before
    asking.
-- 
Ramiro || rbw@demec.ufpe.br